Generate Dynamic R Markdown Blocks

Try knit_expand(): Automate Chunks of Analysis in R Markdown ======================================================== “`{r setup, echo=FALSE} library(knitr) “` “`{r run-numeric-md, include=FALSE} out = NULL for (i in as.character(unique(iris$Species))) { out = c(out, knit_expand(text=”#### Species = {{i}}”)) } “` `r paste(knit(text = out), collapse=”\n”)` You can also create a template file like ‘child.rmd’ and put this in your for … Read more

How to convert R Markdown to PDF?

Updated Answer (10 Feb 2013) rmarkdown package: There is now an rmarkdown package available on github that interfaces with Pandoc. It includes a render 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 … Read more

Add a CSS class to single code chunks in RMarkdown

Edit: this feature was introduced in knitr v.1.16 (05/18/17) class.source and class.output options apply additional HTML classes to source and output chunks (see knitr documentation). To add myClass to source chunk: “`{r cars, class.source=”myClass”} summary(cars) “` Previous answer that inspired the class.source options (see here) You can add a class using the fenced_code_attributes pandoc’s extension … Read more

pandoc version 1.12.3 or higher is required and was not found (R shiny)

Go into RStudio and find the system environment variable for RSTUDIO_PANDOC Sys.getenv(“RSTUDIO_PANDOC”) Then put that in your R script prior to calling the render command. Sys.setenv(RSTUDIO_PANDOC=”— insert directory here —“) This worked for me after I’d been struggling to find how rmarkdown finds pandoc. I had to check github to look at the source.

How to convert R Markdown to HTML? I.e., What does “Knit HTML” do in Rstudio 0.96?

Basic Script So now that the R markdown package has been released, here is some code to replicate the features of Knit to Html. require(knitr) # required for knitting from rmd to md require(markdown) # required for md to html knit(‘test.rmd’, ‘test.md’) # creates md file markdownToHTML(‘test.md’, ‘test.html’) # creates html file browseURL(paste(‘file://’, file.path(getwd(),’test.html’), sep=”)) … Read more

Rstudio rmarkdown: both portrait and landscape layout in a single PDF

So, pandoc does not parse the content of latex environments, but you can fool it by redefining the commands in your header.tex file: \usepackage{lscape} \newcommand{\blandscape}{\begin{landscape}} \newcommand{\elandscape}{\end{landscape}} Thus, here \begin{landscape} is redefined to \blandscape, and \end{landscape} to \elandscape. Using those newly defined command in the .Rmd file seems to work: — title: “Mixing portrait and landscape” … Read more