At the top of every RMarkdown file, you’ll see a YAML
metadata header section enclosed by ---
. By default, it will populate the file title, author, creation date, and output file type, but there are tons of ways to customize it to apply functions and formatting across your entire document. These options can vary by output file type. For .html
files, see here and for .pdf
files, see here.
For our A very important report on global UFO sightings and abductions .html
document, we used the following yaml specifications:
---
title: "A *very* important report on global UFO sightings and abductions"
subtitle: "*(But mainly a lesson on using R Markdown and GitHub Pages to share your work)*"
author: Compiled on Tue Jun 8 20:40:45 2021 by Sam Csik & Juliette Verstaen"
output:
html_document:
code_folding: hide
code_download: true
toc: true
toc_float: true
theme: spacelab
editor_options:
chunk_output_type: console
---
Notice that we can specify both output
and editor_options
. Anything that we specify under output:
applies to our knitted/rendered .html
document, whereas specifying editor_options:
alters RStudio’s default behaviors. For example, I prefer to see outputs rendered in the console when testing (rather than the default in-line renderings).
Other additions we’ve made are:
code_folding:
hide/show; if hide, defaults to collapsed code chunks with the ability to expand/show them individuallycode_download:
provides a button for readers of the page to download the Rmd source filetoc:
true/false; if true, include a Table of Contents based on any specified headerstoc_float:
true/false: if true, Table of Contents floats so that it is always visible, even when the document is scrolledtheme:
set the Bootstrap theme to use across your document; valid themes include default, cerulean, journal, flatly, darkly, readable, spacelab, united, cosmo, lumen, paper, sandstone, simplex, and yeti