简体   繁体   English

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

[英]Using knitr markdown in RStudio calling two different versions of R (2.15.3 and 3.0.2)

I would like to be able to create a Knitr Markdown document calling different versions of R (2.15.3 and 3.0.2) from within R studio.Is this possible? 我希望能够创建一个Knitr Markdown文档,从R studio中调用不同版本的R(2.15.3和3.0.2)。这可能吗? The reason for this is that some packages that have been discontinued may only work in an older version of R 原因是一些已经停产的软件包可能只适用于旧版本的R

For example: 例如:

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)

I added my output here as too large for the comment box Rscript,exe is in: C:\\Program Files\\R\\R-2.15.3\\bin 我在这里添加了输出,因为注释框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'} version ```{r,engine ='Rscript',engine.path ='C / Program Files / R / R-2.15.3 / bin / Rscript'}版本

``` ```

on running KNIT HTML I get the following error 在运行KNIT HTML时出现以下错误

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

Use engine tag: 使用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
```

EDIT add a picture of the knitr preview: 编辑添加knitr预览图片:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM