Re: [Rd] Create an environment and assign objects to it in one go?

From: peter dalgaard <pdalgd_at_gmail.com>
Date: Thu, 10 Mar 2011 08:53:08 +0100

On Mar 10, 2011, at 08:44 , Henrik Bengtsson wrote:

> Hi,
>
> I've just created:
>
> newEnvEval <- function(..., hash=FALSE, parent=parent.frame(), size=29L) {
> envir <- new.env(hash=hash, parent=parent, size=size);
> evalq(..., envir=envir);
> envir;
> } # newEnvEval()
>
> so that I can create an environment and assign objects to it in one go, e.g.
>
> env <- newEnvEval({ a <- 1; b <- 2; });
> print(env$a);
>
> Does this already exists somewhere?
>

I think

env <- local({ a <- 1; b <- 2; environment()}) env$a

-pd

> /Henrik
>
> PS.
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes_at_cbs.dk  Priv: PDalgd_at_gmail.com

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu 10 Mar 2011 - 07:54:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 10 Mar 2011 - 09:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive