Tricks and Solutions

In this chapter we show some tricks that can be useful for writing and compiling reports more easily and quickly, and also solutions to frequently asked questions.

12.1    Chunk Options

There are a number of built-in chunk options in knitr, and we usually assign values to them in chunk headers, but it is still possible to customize these fixed options, e.g., rename the options.

12.1.1  Option Aliases

We may feel some options are very frequently used but the names are too long to type. In this case we can set up aliases for chunk options using the function set_alias() in the beginning of a document, e.g.,


Then we will ...

Get Dynamic Documents with R and knitr, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.