opts_knit: Options for the knitr package

opts_knitR Documentation

Options for the knitr package

Description

Options including whether to use a progress bar when knitting a document, and the base directory of images, etc.

Usage

opts_knit

Format

An object of class list of length 7.

Details

Besides the standard usage (opts_knit$set()), we can also set package options prior to loading knitr or calling knit() using options() in base R. A global option knitr.package.foo in options() will be set as an option foo in opts_knit, i.e. global options in base R with the prefix knitr.package. correspond to options in opts_knit. This can be useful to set package options in ‘~/.Rprofile’ without loading knitr.

See str(knitr::opts_knit$get()) for a list of default package options.

References

Usage: https://yihui.org/knitr/objects/

A list of available options: https://yihui.org/knitr/options/#package-options

Examples

opts_knit$get("verbose")
opts_knit$set(verbose = TRUE)  # change it
if (interactive()) {
    # for unnamed chunks, use 'fig' as the figure prefix
    opts_knit$set(unnamed.chunk.label = "fig")
    knit("001-minimal.Rmd")  # from https://github.com/yihui/knitr-examples
}

knitr documentation built on Sept. 11, 2024, 6:18 p.m.