Skip to content
cpfaff edited this page Jun 23, 2013 · 4 revisions

You need to grab and install a copy of the statistical software package R that suites your operating system. After a successful installation, start up R and install the Knitr package (see box below). You can find documentation about the Knitr package on the authors GitHub account and on the Knitr homepage.

install.packages('knitr', dependencies = TRUE)

The Open-Science-Paper comes with a makefile to compile your document. It is configured to call the knit command directly in console. This works only if you ensure that the directory (R library) you installed the Knitr package to, is listed in your systems search path. For Unix like operating systems you can add a line to the Bash configuration file ".bashrc", located in your home directory (see box below) to ensure this.

  • Open the .bashrc in any editor

vim /home/yourname/.bashrc

  • Add a path pointing to your Knitr binaries

` PATH=$PATH:/path/to/your/R_libs/knitr/bin

  • After that you can do

knit my_knitr_document.Rnw

If you prefer any other console you need to add the line inside of the corresponding configuration file (e.g .zshrc). For other operating systems you may find helpful informations about how to add a directory to the systems search path under the following link.

If you do not like to add a directory to your path variable there is an alternative approach. You can change the Open-Science-Paper makefile to use a command like shown below.

Rscript -e "library(knitr); knit('open_science_paper.Rnw')"

But even if this works fine I recommend you to follow the first approach so you can start right away, using the makefile without any modifications.

Note:

Unfortunately the tikz device for R (which can be used to produce nice plots) has been removed from Cran because due to no maintainer at the moment. If you can grab a copy of it from another source to install it the Open-Science-Paper will use it to create the plots. Otherwise the pdf device will be used. The advantage of using the tikz device is to have the same font and fontsizes within your latex document and your R graphics. You can install the latest version manually by issuing the command below:

install.packages("tikzDevice", repos="http://R-Forge.R-project.org")

Or use the maketask provided by the Open-Science-Paper which does exactly the same for you:

make installtikzdev