[BioC] Assigning values to environments - merging them?

Christos Hatzis christos.hatzis at nuverabio.com
Tue Jun 10 20:33:21 CEST 2008


There is a slightly simpler way for merging two environments using l2e's
second argument:

e3 <- l2e(as.list(e1), e2)

-Christos 

> -----Original Message-----
> From: bioconductor-bounces at stat.math.ethz.ch 
> [mailto:bioconductor-bounces at stat.math.ethz.ch] On Behalf Of 
> James W. MacDonald
> Sent: Tuesday, June 10, 2008 1:45 PM
> To: Helen Zhou
> Cc: bioconductor at stat.math.ethz.ch
> Subject: Re: [BioC] Assigning values to environments - merging them?
> 
> Hi Helen,
> 
> Helen Zhou wrote:
> > Dear Sir/Madam
> > 
> > I have two questions.
> > 
> > 1) I am currently trying to add a lot of values to an 
> environment. A 
> > simplistic example is:
> > 
> > names	<- as.character(1:100000)
> > values	<- data.frame(a=rep("a", 4), b=(rep("b", 4)))
> > environment	<- new.env(parent=emptyenv())
> > for (i in 1:100000) {
> > 	assign(names[i], values, envir=environment)	
> > }
> 
> Ouch! You don't want to do that. See multiassign() in the 
> Biobase package.
> 
> > 
> > I find that as I gets bigger this runs increasingly slow. Is this 
> > caused by the increasing size of the enviroment? Or by 
> something else? 
> > And is there a way for me to avoid this?
> > 
> > 2) Assume that I have two different environments that I 
> would like to 
> > merge into one so all the values are shared, how can I accomplish 
> > this? For example with:
> > 
> > e1 <- new.env(parent = emptyenv())
> > e2 <- new.env(parent = emptyenv())
> > assign("a", 3, envir=e1)
> > assign("b", 4, envir=e2)
> > 
> > how can I join e1 and e2 so I have for example e3 
> containing all the 
> > values. This seems to happen if I
> > have:
> > 
> > e1 <- e2 <- new.env(parent = emptyenv()) assign("a", 3, envir=e1) 
> > assign("b", 4, envir=e2)
> > 
> > but is there a way to do it for enviroments that are 
> already existing.
> 
> I don't know of a way to merge environments directly. 
> However, you could just pull things out of each env into two 
> lists, concatenate, and stuff into a new env.
> 
> l1 <- as.list(e1)
> l2 <- as.list(e2)
> e3 <- l2e(c(l1, l2))
> 
> Best,
> 
> Jim
> 
> 
> 
> > 
> > Thanks you for any help you can give me. I am sorry if my questions 
> > are very simple, but I am a bit confused by the concept of 
> > environemnts and how to work with them.
> > 
> > Yours truly.
> > Mrs Helen Zhou
> > 
> > _______________________________________________
> > Bioconductor mailing list
> > Bioconductor at stat.math.ethz.ch
> > https://stat.ethz.ch/mailman/listinfo/bioconductor
> > Search the archives: 
> > http://news.gmane.org/gmane.science.biology.informatics.conductor
> 
> --
> James W. MacDonald, M.S.
> Biostatistician
> Affymetrix and cDNA Microarray Core
> University of Michigan Cancer Center
> 1500 E. Medical Center Drive
> 7410 CCGC
> Ann Arbor MI 48109
> 734-647-5623
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: 
> http://news.gmane.org/gmane.science.biology.informatics.conductor
> 
>



More information about the Bioconductor mailing list