| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/parser.R |
| 3 |
\name{all_labels} |
| 4 |
\alias{all_labels} |
| 5 |
\alias{all_rcpp_labels} |
| 6 |
\title{Get all chunk labels in a document} |
| 7 |
\usage{ |
| 8 |
all_labels(...) |
| 9 |
|
| 10 |
all_rcpp_labels(...) |
| 11 |
} |
| 12 |
\arguments{ |
| 13 |
\item{...}{A vector of R expressions, each of which should return \code{TRUE} |
| 14 |
or \code{FALSE}. The expressions are evaluated using the \emph{local} chunk |
| 15 |
options of each code chunk as the environment, which means global chunk |
| 16 |
options are not considered when evaluating these expressions. For example, |
| 17 |
if you set the global chunk option \code{opts_chunk$set(purl = TRUE)}, |
| 18 |
\code{all_labels(purl == TRUE)} will \emph{not} return the labels of all |
| 19 |
code chunks, but will only return the labels of those code chunks that have |
| 20 |
local chunk options \code{purl = TRUE}.} |
| 21 |
} |
| 22 |
\value{ |
| 23 |
A character vector. |
| 24 |
} |
| 25 |
\description{ |
| 26 |
The function \code{all_labels()} returns all chunk labels as a character |
| 27 |
vector. Optionally, you can specify a series of conditions to filter the |
| 28 |
labels. The function `all_rcpp_labels()` is a wrapper function for |
| 29 |
\code{all_labels(engine == 'Rcpp')}. |
| 30 |
} |
| 31 |
\details{ |
| 32 |
For example, suppose the condition expression is \code{engine == 'Rcpp'}, the |
| 33 |
object \code{engine} is the local chunk option \code{engine}. If an |
| 34 |
expression fails to be evaluated (e.g. when a certain object does not exist), |
| 35 |
\code{FALSE} is returned and the label for this chunk will be filtered out. |
| 36 |
} |
| 37 |
\note{ |
| 38 |
Empty code chunks are always ignored, including those chunks that are |
| 39 |
empty in the original document but filled with code using chunk options |
| 40 |
such as \code{ref.label} or \code{code}. |
| 41 |
} |
| 42 |
\examples{ |
| 43 |
# the examples below are meaningless unless you put them in a knitr document |
| 44 |
all_labels() |
| 45 |
all_labels(engine == "Rcpp") |
| 46 |
all_labels(echo == FALSE && results != "hide") |
| 47 |
# or separate the two conditions |
| 48 |
all_labels(echo == FALSE, results != "hide") |
| 49 |
} |