Pandoc.brew | R Documentation |
This function behaves just like brew
except for the <%=...%>
tags, where Pandoc.brew
first translate the R object found between the tags to Pandoc's markdown before passing to the cat
function.
Pandoc.brew( file = stdin(), output = stdout(), convert = FALSE, open = TRUE, graph.name, graph.dir, graph.hi.res = FALSE, text = NULL, envir = parent.frame(), append = FALSE, ... )
file |
file path of the brew template. As this is passed to |
output |
(optional) file path of the output file |
convert |
string: format of required output document (besides Pandoc's markdown). Pandoc is called if set via |
open |
try to open converted document with operating system's default program |
graph.name |
character string (default to |
graph.dir |
character string (default to |
graph.hi.res |
render high resolution images of plots? Default is |
text |
character vector (treated as the content of the |
envir |
environment where to |
append |
should append or rather overwrite (default) the |
... |
additional parameters passed to |
This parser tries to be smart in some ways:
a block (R commands between the tags) could return any value at any part of the block and there are no restrictions about the number of returned R objects
plots and images are grabbed in the document, rendered to a png file and pander
method would result in a Pandoc's markdown formatted image link (so the image would be shown/included in the exported document). The images are put in plots
directory in current getwd()
or to the specified output
file's directory.
all warnings/messages and errors are recorded in the blocks and returned in the document as a footnote
Please see my Github page for details (https://rapporter.github.io/pander/#brew-to-pandoc) and examples (https://rapporter.github.io/pander/#examples).
converted file name with full path if convert
is set, none otherwise
Only one of the input parameters (file
or text
) is to be used at once!
Jeffrey Horner (2011). _brew: Templating Framework for Report Generation._ https://cran.r-project.org/package=brew
John MacFarlane (2012): _Pandoc User's Guide_. https://johnmacfarlane.net/pandoc/README.html
## Not run: text <- paste('# Header', '', 'What a lovely list:\n<%=as.list(runif(10))%>', 'A wide table:\n<%=mtcars[1:3, ]%>', 'And a nice chart:\n\n<%=plot(1:10)%>', sep = '\n') Pandoc.brew(text = text) Pandoc.brew(text = text, output = tempfile(), convert = 'html') Pandoc.brew(text = text, output = tempfile(), convert = 'pdf') ## pi is awesome Pandoc.brew(text='<%for (i in 1:5) {%>\n Pi has a lot (<%=i%>) of power: <%=pi^i%><%}%>') ## package bundled examples Pandoc.brew(system.file('examples/minimal.brew', package='pander')) Pandoc.brew(system.file('examples/minimal.brew', package='pander'), output = tempfile(), convert = 'html') Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander')) Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'), output = tempfile(), convert = 'html') ## brew returning R objects str(Pandoc.brew(text='Pi equals to <%=pi%>. And here are some random data:\n<%=runif(10)%>')) str(Pandoc.brew(text='# Header <%=1%>\nPi is <%=pi%> which is smaller then <%=2%>. foo\nbar\n <%=3%>\n<%=mtcars[1:2,]%>')) str(Pandoc.brew(text='<%for (i in 1:5) {%> Pi has a lot (<%=i%>) of power: <%=pi^i%><%}%>')) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.