When you write R Markdown (or Quarto) reports, you are going to have a lot of “chunks” of code. These are the things that start with “```{r chunk_name, blah}” or “```{r, blah}.” When you render your report, these are run and the output is then taken and put in your report depending on how the chunk is configured.
This file gives some options for how to control these chunks.
3.1 Options for including/suppressing code and output
include: Should chunk be included in knit file? Defaults to TRUE. If FALSE, code chunk is run, but chunk and any output is not included in the knit file.
eval: Should chunk be evaluated by R? Defaults to TRUE. If FALSE, code chunk is included in the knit file, but not run.
echo: Should the code from this chunk be included in knit file along with output? Defaults to TRUE. If FALSE, the output from the chunk is included, but the code that created it is not. Most useful for plots.
3.2 Options for including/suppressing R messages
R has “errors” meaning it could not run your code, “warnings” meaning that the code was wrong, but there are some potential issues with it, and “messages” which are simply information about what your code ran. You can include or suppress each of these types of message.
error: Should R continue knitting if code produces an error? Defaults to FALSE. Generally don’t want to change this because it means you can miss serious issues with your code.
warning: Should R include warnings in knit file? Defaults to TRUE.
message: Should R include informational messages in knit file? Defaults to TRUE. Easy way to clean up your markdowns.
#This code produces an errordat %>%filter(dest =1)
Error in `filter()`:
! We detected a named input.
ℹ This usually means that you've used `=` instead of `==`.
ℹ Did you mean `dest == 1`?
At the beginning of your code, you can set custom defaults so all your chunks will render the same way (unless you override by specifically adding arguments to a chunk itself). This is handy in that you will then not need to repeat the custom arguments in each code chunk. For example, you can set a default figure size.