Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rstudio knit to PDF

Tags:

r

rstudio

knitr

The new version of Rstudio (0.98.932) has many new options including knit to PDF. An article describing the new version has a comment from Dave that says:

...after installing rstudio 0.98.932 I don’t get the little dropdown menu for knit-pdf or word when editing a .Rmd file.

I'm having the same issue. A helpful response was posted:

It might be that either:

a) You are not running R 3.0 (which is required for RMarkdown v2); or

b) You have a custom markdown renderer defined (markdownToHTML option). You can check for this by executing:

getOption(“rstudio.markdownToHTML”)

That solved Dave's problem (b), but when I run that command I get NULL

> getOption("rstudio.markdownToHTML")
NULL

Which I assume means I don't have a custom markdown renderer defined. (Previously I did in a cusomized .Rprofile, but I removed that.) My R version is 3.1.0.

Am I misunderstanding the getOption command? Could something else be tripping up my Rstudio?

like image 409
Tom Avatar asked Jun 19 '14 14:06

Tom


People also ask

How do I create a PDF in RStudio?

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.

How do I save a Markdown as a PDF?

Just focus the window containing your markdown file and use the convert command ( Packages > Markdown to PDF > Convert ) or with the following shortcut ctrl-alt-e . The output PDF will be styled similar to the markdown on github.com .

How do I save knitting in RStudio?

If you are using RStudio, then the “Knit” button (Ctrl+Shift+K) will render the document and display a preview of it. Note that both methods use the same mechanism; RStudio's “Knit” button calls rmarkdown::render() under the hood.

How do I knit RStudio to HTML?

To knit in RStudio , click the Knit pull down button. You want to use the Knit HTML option for this lesson. When you click the Knit HTML button, a window will open in your console titled R Markdown. This pane shows the knitting progress.


1 Answers

I have just installed the new version of RStudio (0.98.932), which prompted me to upgrade a couple of packages (I can't remember which, although I see I have knitr 1.6, markdown 0.7 and rmarkdown 0.2.46). At first I had the same problem; there was only a single 'knit' option on the tool bar. I managed to get the ability to knit to .pdf by adding the following to the head of my .Rmd file.

---
title: "Sample Document"
output: pdf_document
---

Having done that, I now find I do have a drop down menu with options to knit to HTML, PDF and word. There's also a little gear icon that provides access to the R Markdown document options that wasn't there before. I have no idea what the problem was but it seems OK now!

like image 101
Nicholas Avatar answered Oct 20 '22 18:10

Nicholas