Chunk options

  • Chunk output can be customized with options.

  • You can see the full list at https://yihui.org/knitr/options.

  • Each of these chunk options get added to the header of the chunk, following #|.

  • The main options are:
    • eval: false prevents code from being evaluated. And obviously if the code is not run, no results will be generated.

    • include: false runs the code, but doesn’t show the code or results in the final document.

    • echo: false prevents code, but not the results from appearing in the finished file.

    • message: false or warning: false prevents messages or warnings from appearing in the finished file.

    • results: hide hides printed output; fig-show: hide hides plots.

    • error: true causes the render to continue even if code returns an error. This is rarely something you’ll want to include in the final version of your report, but can be very useful if you need to debug exactly what is going on inside your .qmd. It’s also useful if you’re teaching R and want to deliberately include an error. The default, error: false causes rendering to fail if there is a single error in the document.