[R] change attributes of all data.frame elements

Jarrod Hadfield j.hadfield at ed.ac.uk
Mon Feb 23 10:32:25 CET 2009


Hi Philipp,

# Sorry - perhaps I wasn't being very clear. For example, creating the  
data frame:

df<-data.frame(y=rnorm(100), x=array(1:100))

# gives 2 elements, the last of which has a dim attribute

lapply(df, dim)

# I would like some way of changing the dim attribute to NULL for all  
elements.

Thanks,

Jarrod



> I was wondering whether there was an easy way to change the attributes
> of all elements in a data.frame (rather than looping through  
> elements)?
>
> Specifically, I would like to set the "dim" attributes to NULL

Maybe I just don't really understand what you are after. The elements
of a data.frame are vectors so by definition they only have one
dimension. Furthermore, they are required to be the same length -
otherwise it wouldn't be a proper data.frame, anymore.

So I guess you really want to accomplish something I didn't quite
grasp. Could you give an example?

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl f?r Genomorientierte Bioinformatik
Technische Universit?t M?nchen
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090223/e1c23106/attachment-0001.pl>


More information about the R-help mailing list