nseval (version 0.4)

dots: Dots objects: lists of quotations.

Description

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.

Usage

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)

Arguments

...

Any number of arguments.

exprs

An expression or list of expressions.

envs

An environment or list of environments.

d

A dots object.

value

A replacement value.

x

A dots object.

drop

See Extract.

row.names

If not given, uses make.unique(x$name)

values

A list; each element will be used as data.

Value

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.

Details

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.

Examples

Run this code
# 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 DataCamp Workspace