克尼特:为什么没有出现在;环境",;编译.Rnw文件时的面板

克尼特:为什么没有出现在;环境",;编译.Rnw文件时的面板,r,rstudio,knitr,R,Rstudio,Knitr,我是个新手。我用一些非常简单的命令制作了一个practice.Rnw文件。例如: \documentclass[12pt, a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{hyperref} \hypersetup{ colorlinks = true, %Colours links instead of ugly boxes urlcolor = blue, %Colour for external hyper

我是个新手。我用一些非常简单的命令制作了一个practice.Rnw文件。例如:

\documentclass[12pt, a4paper]{article}

\usepackage[utf8]{inputenc} 
\usepackage{hyperref}
\hypersetup{
colorlinks   = true, %Colours links instead of ugly boxes
urlcolor     = blue, %Colour for external hyperlinks
linkcolor    = blue, %Colour of internal links
citecolor   = blue %Colour of citations
}
\usepackage{caption}
\captionsetup[figure]{labelfont=bf, labelsep=period}
\captionsetup[table]{labelfont=bf, labelsep=period}
\setlength{\parindent}{0pt}


\title{My very first LaTeX/knitr document!}
\date{April 2019}



\begin{document}

\maketitle

\begingroup
\hypersetup{linkcolor=black} % force independent link colours in table of    contents
\tableofcontents
\endgroup

\newpage

\section{Basics}

\subsection{Using no options}
First, let's try and a show a chunk of code along with a plot and print() message.

<<first-chunk>>=
# Make a simple dataframe:
setwd("/home/user/Documents/testing-area/knitr/")
df <- data.frame(A = c(1,2,3), B = c("A", "B", "C"))
plot(df$A,df$B)
print("hello")
@
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\超设置{
colorlinks=true,%colors链接而不是丑陋的框
urlcolor=蓝色,外部超链接的颜色百分比
linkcolor=蓝色,内部链接的百分比颜色
citecolor=引用的蓝色百分比
}
\usepackage{caption}
\字幕设置[图]{labelfont=bf,labelsep=period}
\字幕设置[表格]{labelfont=bf,labelsep=period}
\setlength{\parindent}{0pt}
\标题{我的第一个LaTeX/knitr文档!}
\日期{2019年4月}
\开始{document}
\maketitle
\起始组
\hypersetup{linkcolor=black}%强制目录中的独立链接颜色
\目录
\端基
\新页
\第{Basics}节
\第{无选项使用}小节
首先,让我们尝试显示一段代码以及一条plot and print()消息。
=
#制作一个简单的数据帧:
setwd(“/home/user/Documents/testing area/knitr/”)

df在RStudio中单击
Compile PDF
编制Rnw文件的常用方法是在独立的R过程中完成的。您的文档在您的工作区中看不到局部变量,并且在其中创建的变量不会持续超过处理时间

有很多方法可以改变这一点。如果在R控制台中明确编织流程,例如

knitr::knit2pdf("file.Rnw")
然后它将能够看到本地工作区中的变量,但它所做的更改不会被保存。要同时保存结果,请使用

knitr::knit2pdf("file.Rnw", envir = globalenv())
这表示在全局环境(即您的工作区)中评估代码