d <- dots(a = one, b = two) captures each of its arguments,
unevaluated, in a dots object (a named list of quotations).
exprs(d) extracts a list of expressions from a dots object.
The mutator exprs(d) <- value returns a new dots object with the new
expressions.
envs(d) extracts a list of environments from a dots
object.
envs(d) <- value replaces the environments with the new
value and returns an updated dots object.
as.data.frame.dots transforms the contents of a dots object
into a data frame with one row per quotation, with columns:
name: a character,
expr: an expression,
env: an environment object or NULL if forced,
value: NULL or a value if forced.
forced_dots_(values) create from dots object from any data.
dots(...)dots_(exprs, envs)
exprs(d)
# S3 method for dots
exprs(d)
exprs(d) <- value
# S3 method for dots
exprs(d) <- value
envs(d)
# S3 method for dots
envs(d)
envs(d) <- value
# S3 method for dots
envs(d) <- value
# S3 method for dots
[(x, ..., drop = FALSE)
# S3 method for dots
[(x, ...) <- value
# S3 method for dots
c(...)
# S3 method for quotation
c(...)
# S3 method for dots
as.data.frame(x, row.names = NULL, ...)
forced_dots_(values)
Any number of arguments.
An expression or list of expressions.
An environment or list of environments.
A dots object.
A replacement value.
A dots object.
See Extract.
If not given, uses make.unique(x$name)
A list; each element will be used as data.
A list with class 'dots', each element of which is a quotation.
dots_(exprs, envs) directly constructs a dots object
given lists of expresions and environments.
exprs returns a named list of expressions.
envs(d) returns a named list of environments.
as.data.frame.dots returns a data frame.
Objects of class "dots" mirror R's special variable ....
Unlike ..., a dots is:
immutable (evaluating does not change it),
first-class (you can give it any name, not just ...),
data (The R interpreter treates it as literal data rather than triggering argument splicing).
d <- dots(...) can be used to capture the contents of ...
without triggering evaluation. This improves on substitute(...())
by capturing the environment of each component along with the
expressions.
# NOT RUN {
named.list <- function(...) {
# Collect only named arguments, ignoring unnamed arguments.
d <- dots(...)
do(list, d[names(d) != ""])
}
named.list(a=1, b=2*2, stop("this is not evaluated"))
# }
Run the code above in your browser using DataLab