d <- dots(a = one, b = two) captures each of its arguments,
unevaluated, in a dots object (a named list of quotations).
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(...) forces its arguments and constructs a dots object with
forced quotations.
forced_dots_(values) creates a dots object from a list of values
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
[(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(...)
forced_dots_(values)
dots(...) constructs a list with class 'dots', each
element of which is a quotation.
dots_(exprs, envs) constructs a dots object given lists
of expressions and environments. (To construct a dots object from
quotation objects, use c().)
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) returns a named list of environments.
envs(d) <- value returns an updated dots object with the
environments replaced with the new value(s).
as.data.frame.dots returns a data frame.
Any number of arguments.
An expression or list of expressions.
An environment or list of environments.
A dots object.
A replacement value or list of values.
A dots object.
See Extract.
If not given, uses make.unique(x$name)
A list; each element will be used as data.
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(...) is used to capture the contents of ... without
triggering evaluation. This improves on
as.list(substitute(...())) by capturing the environment of each
argument along with their expressions. (You can also use
get_dots().)
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