[R] Suggestion on how to make permanent changes to a singleobject in a list?

Peter Waltman waltman at cs.nyu.edu
Fri Jan 4 06:06:49 CET 2008


> fooStack[[1]]  <- fooModifier(fooStack[[1]])
I thought of this idea as well, and may go with it, if the Gabor's 
environments idea doesn't work

> snip
>
> Peter, perhaps it would help if you gave us more context into why you 
> wanted this done, and perhaps then someone can suggest a more natural 
> approach. Perhaps there is a more "R" way to solve your original problem.
it's fairly simple, but basically, we have a "cluster" object (which is 
really just a list) that has several items in it, one of which is 
something that we call a colslice (basically, just several columns of 
expression matrices).  In reality, this cluster is part of a larger 
"meta-cluster" for genes from several different organisms.

So, really the structure is:

clusterStack ( == list() )
clusterStack[[ 1 ]] = a cluster of the form:

cluster (== list() )
|
|->>cluster$bsubt ( == list() )
       |
       |--->cluster$bsubt$colslice
       |--->cluster$bsubt$cols
       |--->cluster$bsubt$rowslice
       |--->cluster$bsubt$genes
|->>cluster$banth ( == list() )
       |
       |--->cluster$banth$colslice
       |--->cluster$banth$cols
       |--->cluster$banth$rowslice
       |--->cluster$banth$genes


I'm writing a function that will be called by another which generates 
the clusters and clusterStack objects, and the inner function should 
return the results some calculations on the $colslice and $rowslice items.

I just wanted to have the inner function to retrieve the row/col slices 
from a MySQL database in case they haven't been set.

The other workaround is just to make sure that they're already set by 
the time the function is called, and have the function throw an error if 
they're not.  In fact, that might be the better way to do it, to provide 
better "encapsulation".

I just wanted to see if it was possible to have the inner function set 
these.

Thanks for all the suggestions!

Peter




More information about the R-help mailing list