render_doc | R Documentation |
render_doc
renders an R Markdown in a fresh R process using
callr
render_doc( input, input_basedir = NULL, output_basedir = getOption("rutils.render.output_basedir"), output_dir = NULL, output_file = NULL, output_formats = NULL, params = NULL, open = FALSE, root = rprojroot::is_git_root | rprojroot::is_rstudio_project, ... )
input |
Input file |
input_basedir |
Base input directory (optional). If not specified,
will be the first subfolder of the input file within the root directory.
For example, for input |
output_basedir |
Base output directory (default takes from the option
|
output_dir |
Directly specify the output directory.
If specified, takes precedence over |
output_file |
Optional, the filename of the output file(s).
If not provided, the default is the input filename.
Any directory part of |
output_formats |
Optional, a vector of output file formats to which to render.
If not provided, All available R Markdown
output formats
are supported.
In parentheses, the extensions file extensions that will be created are specified.
For example, the format
|
params |
Parameters in the R Markdown document to execute |
open |
Whether to open the output document using rstudioapi::viewer |
root |
Root criterion using a specification from rprojroot::root_criterion. Determines the root folder. |
... |
Additional arguments passed to rmarkdown::render |
This function assumes you are working within a project structure,
specifically an RStudio project. The output file will be saved at the
same location relative to output_basedir
as input
is
relative to input_basedir
. For example, using the defaults,
if the input file is code/folder1/folder2/report.Rmd
, the
output file will be saved to output/folder1/folder2/report.html
.
The user may select base input and output directories, relative
to which the paths are computed. The user may also directly
specify the output directory if preferred.
To use this function in a R Markdown document, you can place the following line in the YAML header:
knit: (function(inputFile, encoding) rutils::render_doc(inputFile))
If rendering to multiple formats, keep in mind that the R code is executed again for each format, as noted here. Therefore, for documents that take a lengthy period of time to run, it may not preferable to render to multiple formats.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.