all_labels {knitr}R Documentation

Get all chunk labels in a document

Description

The function all_labels() returns all chunk labels as a character vector. Optionally, you can specify a series of conditions to filter the labels. The function 'all_rcpp_labels()' is a wrapper function for all_labels(engine == 'Rcpp').

Usage

all_labels(...)

all_rcpp_labels(...)

Arguments

...

a series of R expressions, each of which should return TRUE or FALSE; the expressions are evaluated using the local chunk options of each code chunk as the environment

Details

For example, suppose the condition expression is engine == 'Rcpp', the object engine is the local chunk option engine; if an expression fails to be evaluated (e.g. when a certain object does not exist), FALSE is returned and the label for this chunk will be filtered out.

Value

A character vector.

Note

Empty code chunks are always ignored, including those chunks that are empty originally in the document but filled with code using chunk options such as ref.label or code.

Examples

# the examples below are meaningless unless you put them in a knitr document
all_labels()
all_labels(engine == "Rcpp")
all_labels(echo == FALSE && results != "hide")
# or separate the two conditions
all_labels(echo == FALSE, results != "hide")

[Package knitr version 1.15.20 Index]