New Wine in an Old Bottle: R Markdown v2 and R Studio on the Cent OS Server

[This article was first published on A Statistics Blog - R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Introduction

R Markdown Version 2 is a boon to students: with a single click one can convert an R Markdown file to either HTML, PDF or Word format. However, getting this feature to work fully in the R Studio server environment may require a bit of work, especially if you running the Server on a Cent OS distribution. Although I am sure that Cent OS has many virtues, an up-to-date repository is not among them.

This post is the record of an arm wrasslin’ match with Cent OS and the R Studio Server version 0.98.932, from which I emerged more or less victorious. If your IT department hosts RStudio on CentOS, then perhaps the following remarks will make your life a bit easier. On the other hand, if you know your way around Linux better than I do, please feel free to offer quicker or better solutions in the Comments.

Log on to the server, perhaps through ssh (secure shell). Come armed with administrative privileges.

New Pandoc

R Markdown v2 uses a newer version of the pandocconverter than the one available in the Cent OS repository. Fortunately, R Studio comes bundled with the binaries of a sufficiently recent version of pandoc. You obtain access to these files by establishing symbolic links in the /usr/local/bin directory to the pandoc and pandoc-cite binaries:

1
2
<span class="line">sudo ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc-citeproc /usr/local/bin
</span><span class="line">sudo ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc /usr/local/bin
</span>

Installing LaTeX Packages

You can get Tex Live from the Cent OS repositories, but the release appears to date back to the year 2007. Therefore it lacks a couple of packages needed by pandoc:

Since you will download these packages from the Comprehensive Tex Archive Network, you’ll want a web-fetch utility such as wget. If it’s not already installed on Cent OS, you can get it with:

1
<span class="line">sudo yum install wget
</span>

Now you can grab the relevant files with wget:

1
2
<span class="line">wget http://www.ctan.org/tex-archive/macros/latex/contrib/oberdiek/ifluatex.dtx
</span><span class="line">wget http://mirrors.ctan.org/macros/latex/contrib/framed.zip
</span>

Turning first to ifluatex, we begin by by unpacking the .dtx bundle. This is accomplished with a tex command:

1
<span class="line">tex ifluatex.dtx
</span>

Several files spill out into your Home directory. You care only about ifluatex.sty. Copy it as follows:

1
<span class="line">sudo cp ifluatex.sty /usr/share/texmf/tex/generic/oberdiek
</span>

As for the framed package, you must first unzip the downloaded file into a directory:

1
2
<span class="line">mkdir framed
</span><span class="line">unzip framed.zip -d framed
</span>

Now copy the framed directory as follows:

1
<span class="line">sudo cp -rf framed /usr/share/texmf/tex/latex
</span>

Finally, you need to make tex aware of the existence of these new packages with texhash:

1
<span class="line">sudo texhash
</span>

Now you may Knit to your heart’s content!

To leave a comment for the author, please follow the link and comment on their blog: A Statistics Blog - R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)