

For example, if you want to include a table of contents you would modify the output: field in the YAML header as followsĪs mentioned above, one of the great things about R markdown is that you don’t need to rely on your word processor to bring your R code, analysis and writing together. Also, indentation in the YAML header has a meaning, so be careful when aligning text.

If you need multiple output formats for your R markdown document check whether your YAML options are compatible between these formats.
RMARKDOWN PLOT SIZE PDF
Just a note of caution, many of the options you can specify in the YAML header will work with both HTML and pdf formatted documents, but not all. If you want to explore the plethora of other options see here.

You can also change the default font and font size for the whole document and even include fancy options such as a table of contents and inline references and a bibliography. If you would like to change the output to pdf format then you can change it from output: html_document to output: pdf_document (you can also set more than one output format if you like). In the YAML header above the output format is set to HTML. title : My first R markdown document author : Jane Doe date : Maoutput : html_document.
RMARKDOWN PLOT SIZE CODE
R plots in code chunks are first recorded via a graphical device in knitr, and then written out to files. Caching can be handy but also tricky sometimes.įig.width and fig.height: The (graphical device) size of R plots in inches. However, I want to honestly remind you of the two hard problems in computer science (via Phil Karlton): naming things, and cache invalidation. If caching is enabled, the same code chunk will not be evaluated the next time the document is compiled (if the code chunk was not modified), which can save you time. When you are trying to set echo = FALSE, results = 'hide', warning = FALSE, and message = FALSE, chances are you simply mean a single option include = FALSE instead of suppressing different types of text output individually.Ĭache: Whether to enable caching. When include = FALSE, this whole code chunk is excluded in the output, but note that it will still be evaluated if eval = TRUE. Include: Whether to include anything from a code chunk in the output document. Similarly, when warning = FALSE or message = FALSE, these messages will be shown in the R console. Note that if you set error = FALSE, rmarkdown::render() will halt on error in a code chunk, and the error will be displayed in the R console. Warning, message, and error: Whether to show warnings, messages, and errors in the output document. The default collapse = FALSE means R expressions and their text output are separated into different blocks. This is mostly cosmetic: collapse = TRUE makes the output more compact, since the R source code and its text output are displayed in a single output block. By default, text output will be wrapped in verbatim elements (typically plain code blocks).Ĭollapse: Whether to merge text output and source code into a single code block in the output. Results: When set to 'hide', text output will be hidden when set to 'asis', text output is written “as-is”, e.g., you can write out raw Markdown text from R code (like cat('**Markdown** is cool.\n')). We list a subset of them below:Įcho: Whether to echo the source code in the output document (someone may not prefer reading your smart source code but only results). There are a large number of chunk options in knitr documented at.

