opts_hooks

0th

Percentile

Hooks for code chunk options

Like knit_hooks, this object can be used to set hook functions to manipulate chunk options.

Keywords
datasets
Usage
opts_hooks
Details

For every code chunk, if the chunk option named, say, FOO, is not NULL, and a hook function with the same name has been set via opts_hooks$set(FOO = function(options) { options }) (you can manipuate the options argument in the function and return it), the hook function will be called to update the chunk options.

Format

An object of class list of length 4.

References

https://yihui.name/knitr/hooks/

Aliases
  • opts_hooks
Examples
# NOT RUN {
# make sure the figure width is no smaller than fig.height
opts_hooks$set(fig.width = function(options) {
    if (options$fig.width < options$fig.height) {
        options$fig.width = options$fig.height
    }
    options
})
# remove all hooks
opts_hooks$restore()
# }
Documentation reproduced from package knitr, version 1.16, License: GPL

Community examples

Looks like there are no examples yet.