Chapter 23. R Markdown Formats
Introduction
So far you’ve seen R Markdown used to produce HTML documents. This chapter gives a brief overview of some of the many other types of output you can produce with R Markdown. There are two ways to set the output of a document:
-
Permanently, by modifying the the YAML header:
title:"ViridisDemo"output:html_document -
Transiently, by calling
rmarkdown::render()by hand:rmarkdown::render("diamond-sizes.Rmd",output_format="word_document")This is useful if you want to programmatically produce multiple types of output.
RStudio’s knit button renders a file to the first format listed in its
output field. You can render to additional formats by clicking the
drop-down menu beside the knit button.
Output Options
Each output format is associated with an R function. You can either
write foo or pkg::foo. If you omit pkg, the default is assumed to
be rmarkdown. It’s important to know the name of the function that makes
the output because that’s where you get help. For example, to figure out
what parameters you can set with html_document, look at
?rmarkdown:html_document().
To override the default parameter values, you need to use an expanded
output field. For example, if you wanted to render an html_document
with a floating table of contents, you’d use:
output:html_document:toc:truetoc_float:true
You can even render to multiple ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access