在RStudio中使用knitr markdown调用两个不同版本的R(2.15.3和3.0.2)

时间:2013-12-13 22:24:14

标签: r markdown knitr rstudio

我希望能够创建一个Knitr Markdown文档 从R studio中调用不同版本的R(2.15.3和3.0.2)。这可能吗? 原因是一些已停产的包装可能只是 在较旧版本的R中工作

例如:

Title
========================================================

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I would like to run a package from
R version 2.15.3 (2013-03-01) -- "Security Blanket"
here:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

```{r}
summary(cars)
```

embed plots:

```{r fig.width=7, fig.height=6}
plot(cars)
```
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I would like to run a package from
R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"

here:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

``{r}
summary(cars)
```

 embed plots:

 ```{r fig.width=7, fig.height=6}
 plot(cars)

我在这里添加的输出对于评论框来说太大了 Rscript,exe在: C:\ Program Files \ R \ R-2.15.3 \ bin

```{r,engine ='Rscript',engine.path ='C / Program Files / R / R-2.15.3 / bin / Rscript'} 版本

```

运行KNIT HTML时出现以下错误

系统错误(cmd,intern = TRUE):   '“未找到C / Program Files / R / R-2.15.3 / bin / Rscript”

1 个答案:

答案 0 :(得分:10)

使用engine代码:

```{r,engine='Rscript', engine.path='PATH_TO/R/R-3.0.2/bin/Rscript'}
version
```

```{r,engine='Rscript', engine.path='PATH_TO/R/R-2.15.3/bin/Rscript'}
version
```

编辑添加针织预览的图片:

enter image description here