Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>Updated Answer (10 Feb 2013)</h3> <p><strong>rmarkdown package</strong>: There is now an <a href="https://github.com/rstudio/rmarkdown" rel="noreferrer"><code>rmarkdown</code> package available on github</a> that interfaces with Pandoc. It includes a <code>render</code> function. The documentation makes it pretty clear how to convert rmarkdown to pdf among a range of other formats. This includes including output formats in the rmarkdown file or running supplying an output format to the rend function. E.g.,</p> <pre><code>render("input.Rmd", "pdf_document") </code></pre> <p><strong>Command-line:</strong> When I run <code>render</code> from the command-line (e.g., using a makefile), I sometimes have issues with pandoc not being found. Presumably, it is not on the search path. The following answer explains <a href="https://stackoverflow.com/a/29710643/180892">how to add pandoc to the R environment</a>.</p> <p>So for example, on my computer running OSX, where I have a copy of pandoc through RStudio, I can use the following:</p> <pre><code>Rscript -e "Sys.setenv(RSTUDIO_PANDOC='/Applications/RStudio.app/Contents/MacOS/pandoc');library(rmarkdown); library(utils); render('input.Rmd', 'pdf_document')" </code></pre> <hr> <h3>Old Answer (circa 2012)</h3> <p>So, a number of people have suggested that Pandoc is the way to go. See notes below about the importance of having an up-to-date version of Pandoc.</p> <h3>Using Pandoc</h3> <p>I used the following command to convert R Markdown to HTML (i.e., <a href="https://stackoverflow.com/a/10969107/180892">a variant of this makefile</a>), where <code>RMDFILE</code> is the name of the R Markdown file without the <code>.rmd</code> component (it also assumes that the extension is <code>.rmd</code> and not <code>.Rmd</code>). </p> <pre><code>RMDFILE=example-r-markdown Rscript -e "require(knitr); require(markdown); knit('$RMDFILE.rmd', '$RMDFILE.md'); markdownToHTML('$RMDFILE.md', '$RMDFILE.html', options=c('use_xhml'))" </code></pre> <p>and then this command to convert to pdf</p> <pre><code>Pandoc -s example-r-markdown.html -o example-r-markdown.pdf </code></pre> <p><hr /> A few notes about this:</p> <ul> <li>I removed the reference in the example file which exports plots to imgur to host images.</li> <li>I removed a reference to an image that was hosted on imgur. Figures appear to need to be local.</li> <li>The options in the <code>markdownToHTML</code> function meant that image references are to files and not to data stored in the HTML file (i.e., I removed <code>'base64_images'</code> from the option list).</li> <li>The resulting output looked like <a href="http://cloud.github.com/downloads/jeromyanglim/assorted-files/example-r-markdown.pdf" rel="noreferrer">this</a>. It has clearly made a very LaTeX style document in contrast to what I get if I print the HTML file to pdf from a browser.</li> </ul> <h3>Getting up-to-date version of Pandoc</h3> <p>As mentioned by @daroczig, it's important to have an up-to-date version of Pandoc in order to output pdfs. On Ubuntu as of 15th June 2012, I was stuck with version 1.8.1 of Pandoc in the package manager, but it seems from the <a href="http://johnmacfarlane.net/pandoc/releases.html" rel="noreferrer">change log</a> that for pdf support you need at least version 1.9+ of Pandoc.</p> <p>Thus, I installed <code>caball-install</code>. And then ran:</p> <pre><code>cabal update cabal install pandoc </code></pre> <p>Pandoc was installed in <code>~/.cabal/bin/pandoc</code> Thus, when I ran <code>pandoc</code> it was still seeing the old version. See here for <a href="https://askubuntu.com/a/33443/2521">adding to the path</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload