Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? The reason for this is that some packages that have been discontinued may only work in an older version of 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

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

```

on running KNIT HTML I get the following error

Error in system(cmd, intern = TRUE) : '"C/Program Files/R/R-2.15.3/bin/Rscript"' not found

like image 818
adam.888 Avatar asked Dec 13 '13 22:12

adam.888


1 Answers

Use engine tag:

```{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:

enter image description here

like image 142
agstudy Avatar answered Oct 18 '22 14:10

agstudy