我正在使用RStudio版本0.97.312运行R版本2.15.3.我有一个脚本从各种来源读取我的数据并创建几个data.tables.然后我有另一个r脚本,它使用在第一个脚本中创建的data.tables.我想将第二个脚本转换为R降价脚本,以便分析结果可以作为报告输出.
我不知道的目的read_chunk,而不是source.我read_chunk没有工作,但source正在工作.无论哪种情况,我都无法在RStudio的工作区面板中看到对象.
请解释之间的差异read_chunk和source?我为什么要使用其中一个?为什么我的.Rmd脚本不起作用
这是行不通的.我收到以下消息
错误:找不到对象'z'
两个简单的文件......
测试源到rmd.R
x <- 1:10
y <- 3:4
z <- x*y
Run Code Online (Sandbox Code Playgroud)
测试源.Rmd
Can I run another script from Rmd
========================================================
Testing if I can run "test of source to rmd.R"
```{r first part}
require(knitr)
read_chunk("test of source to rmd.R")
a <- z-1000
a
```
The above worked only if I replaced "read_chunk" with "source". I
can use the vectors outside of the code chunk as in inline usage.
So here I will tell you that the first number is `r a[1]`. The most
interesting thing is that I cannot see the variables in RStudio
workspace but it must be there somewhere.
Run Code Online (Sandbox Code Playgroud)
Yih*_*Xie 13
read_chunk()只读取源代码(以供将来参考); 它没有评估代码source().本页以及手册中read_chunk()解释了目的.