From pdalgd at gmail.com  Thu Mar 10 08:53:08 2011
From: pdalgd at gmail.com (peter dalgaard)
Date: Thu, 10 Mar 2011 08:53:08 +0100
Subject: [Rd] Create an environment and assign objects to it in one go?
In-Reply-To: <AANLkTi=n9v0ebCbcsqtZCGQEtUa2nN_rUpoM+0uf0shS@mail.gmail.com>
References: <AANLkTi=n9v0ebCbcsqtZCGQEtUa2nN_rUpoM+0uf0shS@mail.gmail.com>
Message-ID: <E7DA099E-BF66-484D-B4EC-FAC4E79A4362@gmail.com>


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



[Rd] Create an environment and assign objects to it in one go?
peter dalgaard