[R] lapply drops colnames

Jack Tanner ihok at hotmail.com
Tue Aug 3 00:35:36 CEST 2004


Wolski wrote:
> What you can do is to extend the column (list) by an addtional attribute  attr(mydataframe[i],"info")<-names(mydataframe)[i] and store theyr names in it.

OK, that's brilliant. Any ideas on how to do this automatically for 
every column in my dataframe? lapply(dataframe... fails for the obvious 
reason. Should I do something like this, or is for() to be avoided even 
in this case?

 > for(i in 1:length(a)) {print(names(a)[i])}




More information about the R-help mailing list