We will now add some additional YAML
metadata and document options.
Also here, knit your document often, to see the difference that the options make to the document and to make sure that there is no bug.
If there is an error while knitting, read the error message and see if it’s something about the YAML header. If yes, check if the indentation is correct. This is a frequent source of errors.
In this task, focus on the document type that you like to learn most. If you don’t know yet, I suggest HTML as it has the most options and works smoothly.
As a starting point, add the 3 document output types html_document
, pdf_document
and word_document
with their default specification to the YAML header.
If you use an open office instead of MS Word, use odt_document
instead of word_document
.
Make sure that the indentation is correct. If you want to make sure that everything works, try knitting to the different output formats using the little arrow next to the knit button.
Note here, that unfortunately the pdf version cannot deal with images fetched directly from the internet. So you can’t include the penguin picture in pdf output. If you decide to focus on pdf output, you have two options:

or using a code chunk and knitr::include_graphics("local/path/to/file.png")
)Now start adding YAML options to your favorite document type. When you are finished, you can move to another document type as well.
Play with the combinations of document types and options from the slides.
Some ideas to try are: