Session Ready
Exercise

R code chunk options

You've been introduced to some R code chunk options in the video. R code chunks can also be named. This makes sense in large documents, especially if there is an error inside a chunk. While knitting a document in RStudio, for example, the error can then be located in an easier fashion. Some chunks in your report have been named so you get the idea behind that concept. Chunk options are added after the name of the chunk and a comma, like so: {r name, option = value}

Probably among the most used chunk options are the ones for controlling the display of the output. By default, all output is shown in RMarkdown documents, i.e. messages, warnings and errors. By specifying options like echo = FALSE, you can suppress the display of the R code itself, for example, while the code itself is still evaluated. Refer to the video for more display options.

Remember to separate your chunk name and chunk options with a comma to prevent your session from crashing.

Instructions
100 XP
  • On line 14, suppress messages in the first R code chunk with the message option, such that the output that is sometimes generated when loading packages is not shown.
  • On line 64, the chunk defining_a_theme enriches your report with a custom plot, however the code behind it is not so important for the readers of your report.
    • Hide all the code, but let R evaluate it nonetheless (if you don't remember the chunk option, re-watch the video).