This function creates the Rmd file which will be rendered in a specific format.
Usage
generate_rmd_file(
content,
output_format = c("word", "pdf", "html", "word_document", "pdf_document",
"html_document"),
font_size = 12,
code = TRUE,
font_path = get_fira_path(),
word_template_path = get_word_template_path(),
...
)
Arguments
- content
a string. The body of the Rmd file (for example code or text)
- output_format
a string representing the output format. The values
"pdf"
,"html"
or"word"
and their knitr equivalent"pdf_document"
,"html_document"
or"word_document"
are accepted.- font_size
a numeric. The font size, only available in pdf format.
- code
a boolean. Should the
content
string have to be inserted in R chunk or is it just text? Default is TRUE (so thecontent
will be inserted in R chunk).- font_path
a string. The path to the font used to render code chunks. It should link to a
.ttf
file. Only available in pdf format.- word_template_path
a string. The path to the word template file used when rendering with word. By default, the template used is the one included in the package. Only used with word output.
- ...
other arguments passed to R chunk (for example
eval = TRUE
,echo = FALSE
...)
Details
More information about the argument ... in the documentation of the
function render_code
.
Examples
generate_rmd_file(content = "Bonjour tout le monde",
code = FALSE,
output_format = "word")
#> [1] "---\ntitle: \"Format code\"\noutput:\n word_document:\n highlight: arrow\n reference_docx: \"/home/runner/work/_temp/Library/TBox/extdata/template.docx\"\ncode-block-bg: true\ncode-block-border-left: \"#31BAE9\"\n---\n\n## Running Code\n\n\nBonjour tout le monde\n\n"
generate_rmd_file(content = "print(AirPassengers)",
code = TRUE,
output_format = "pdf",
eval = TRUE,
echo = FALSE)
#> [1] "---\ntitle: \"Format code\"\noutput:\n pdf_document:\n highlight: arrow\n fig_crop: true\n latex_engine: xelatex\ncode-block-bg: true\ncode-block-border-left: \"#31BAE9\"\n---\n\n\\fontsize{12}{12}\n\\setmonofont[ExternalLocation=/home/runner/work/_temp/Library/TBox/extdata/FiraCode/]{FiraCode-Regular.ttf}\n\n## Running Code\n\n```{r, eval = TRUE, echo = FALSE}\nprint(AirPassengers)\n```\n"
generate_rmd_file(content = "plot(AirPassengers)",
code = TRUE,
output_format = "html_document",
eval = FALSE,
echo = TRUE)
#> [1] "---\ntitle: \"Format code\"\noutput:\n html_document:\n highlight: arrow\nmonofont: \"Fira Code\"\ncode-block-bg: true\ncode-block-border-left: \"#31BAE9\"\n---\n\n## Running Code\n\n```{r, eval = FALSE, echo = TRUE}\nplot(AirPassengers)\n```\n"