Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling *.Rnw files with knitr --without Rstudio

Tags:

vim

r

knitr

I would like to use knitr to create presentations that embed R objects and code.

For IT reasons I am restricted to vim, so i have found the available Rstudio+knitr examples fairly unhelpful. The vim section of the knitr documents is also very skinny, and therefore unhelpful.

Is someone able to provide some guidance on how to compile a *.Rnw or *.Rmd file using knitr (or alternately point me to a decent online tutorial?) using some combination of vim, R, and the command line?

thanks in advance

like image 736
ricardo Avatar asked Jul 15 '13 23:07

ricardo


1 Answers

Instead of going through Rstudio, you can use the functions in the knitr package directly. There are some options you can tweak, but to get started, all you have to do is call the knit() function on your .Rnw file:

library(knitr)
knit('my_input.Rnw')

If you're missing some of Rstudio's features, it's worth remembering that most of them are just making use of things that are already available in various R packages, so you can usually find a way to use them when you don't have Rstudio available.

like image 110
Marius Avatar answered Oct 18 '22 20:10

Marius