[BioC] Assigning values to environments - merging them?

Helen Zhou zhou.helen at yahoo.com
Tue Jun 10 18:36:12 CEST 2008


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)	
}

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.

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



More information about the Bioconductor mailing list