env

0th

Percentile

Creates a new environment, evaluates an expression therein, and returns the environment

Creates a new environment, evaluates an expression therein, and returns the environment.

Keywords
utilities, device
Usage
env(..., hash=FALSE, parent=parent.frame(), size=29L)
Arguments
...

Arguments passed to evalq(), particularly a expression to be evaluated inside the newly created environment.

hash, parent, size

Arguments passed to new.env().

Value

Returns an environment.

References

[1] R-devel thread 'Create an environment and assign objects to it in one go?' on March 9-10, 2011.

See Also

Internally new.env() and evalq() are used.

Aliases
  • env
Examples
# NOT RUN {
x <- list();

x$case1 <- env({
 # Cut'n'pasted from elsewhere
 a <- 1;
 b <- 2;
});

x$case2 <- env({
 # Cut'n'pasted from elsewhere
 foo <- function(x) x^2;
 a <- foo(2);
 b <- 1;
 rm(foo); # Not needed anymore
});

# Turn into a list of lists
x <- lapply(x, FUN=as.list);

str(x);
# }
Documentation reproduced from package R.utils, version 2.8.0, License: LGPL (>= 2.1)

Community examples

Looks like there are no examples yet.