[BioC] assigning phenoData via assign

Seth Falcon sfalcon at fhcrc.org
Mon May 7 19:12:57 CEST 2007


Hi Benilton,

Benilton Carvalho <bcarvalh at jhsph.edu> writes:
> I'm trying to set the phenoData slot using get() or something  
> similar, eg:

First of all, you probably want to use phenoData(foo) <- updatedPheno,
not direct slot access.

> library(Biobase)
> objName <- "sample.ExpressionSet"
> data(list=objName)
> pd <- phenoData(get(objName))
>
> get(objName)@phenoData <- pd    ## this will fail

Perhaps it would help if you gave some context of what it is you are
trying to achieve.

Conceptually, get() returns a copy of the object requested and it
doesn't make sense to modify an anonymous copy.

Any modification of an object results in a copy (there are exceptions,
but let's ignore them for now).  But R is clever about when the copy
is actually made (just assigning to a tmp var doesn't trigger a copy).

> I could copy the object to a temporary one:
>
> tmp <- get(objName)
> tmp at phenoData <- pd
> assign(objName, tmp)
> rm(tmp)
>
> how can I avoid this copy?

I'm not sure you can, but maybe I'm not understanding what you really
want to do.

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org



More information about the Bioconductor mailing list