1

I'm trying to generate a report with a number of plots (the result of applying the same analysis to a list of data.frames). The pander package makes this pretty easy:

myReport <- Pandoc$new("Tyler", "test")
myReport$add.paragraph("# First section")
myReport$add(plot(1:10))
myReport$add.paragraph("# Second section")
myReport$add(plot(sin(seq(1, 2* pi, length = 20))

myReport$export()

This generates a nice pdf with all the plots. However, I can't figure out how to control the formatting in pandoc. For example, I don't want a table of contents, I want to control (reduce) the size of the images, and have them placed in-line, not floated. How do I set this in pander, or pass the appropriate arguments to Pandoc?

If this isn't possible, is there a better package for this? I know knitr provides this kind of control, but I need to generate the source markdown from R -- I don't think knitr does that. That is, knitr converts Rmd -> md -> PDF, but you still need to write the Rmd file by hand. I need to generate the Rmd (or just md) from R code.

Carl
  • 5,569
  • 6
  • 39
  • 74
Tyler
  • 9,872
  • 2
  • 33
  • 57
  • I'm not entirely sure this is possible with the Pandoc R5 class, but if I understand the last sentence correctly you should be able to generate the source markdown with `knitr` see: http://stackoverflow.com/questions/24292909/new-r-studio-version-0-98-932-deletes-md-file-how-to-prevent – Carl Jul 08 '16 at 21:17
  • @Carl I mean I need to generate the (R)md source from R code. knitr will generate md from Rmd, but I don't think it has functions to generate Rmd (or plain md) from R code. – Tyler Jul 08 '16 at 21:42
  • I see. This is something that I've spent a decent amount of time thinking about. You could use `sink` and `cat` to write out the .rmd literally, which is not crazy difficult, but not ideal. I'm pretty sure `rmarkdown` has similar functionality to what you are doing in `pander`, but I can't find the documentation. Will keep looking. – Carl Jul 08 '16 at 21:52
  • This may be your best bet: http://rmarkdown.rstudio.com/developer_parameterized_reports.html – Carl Jul 08 '16 at 22:07
  • 2
    As `Pandoc$export` is just a wrapper around `Pandoc.convert`, you can use the `options` argument to pass command line options to `pandoc`. So this let's you specify a custom LaTeX template etc, but if you want more control, you'd better preprocess and Rmd (eg with `brew` or rather `Pandoc.brew` with all the extra features from the `pander` package). – daroczig Jul 08 '16 at 22:58
  • @daroczig I see. Maybe this is implied in the documentation, but it's not explicit. It would be nice to have a complete list of the options/slots for the Pandoc class, along with an explanation of what values they can take and what they actually do. Or at least a link to other documentation, such as `$export` passes arguments to `Pandoc.convert`. – Tyler Jul 09 '16 at 12:07

0 Answers0