[R] convert a list to a data frame

Sam Steingold sds at gnu.org
Wed Apr 4 22:54:57 CEST 2012


> * Sam Steingold <fqf at tah.bet> [2012-04-04 14:58:15 -0400]:
>
> 1. the strings I replaced with ZZZZ and YYYY are very long; I wish I
> could replace them in the object all, not just in text

i.e., I have a long list with elements with long names.
how do I replace all these long names with something shorter?
row.names(list) <- ...
does not do the trick.

>> lapply(all.v,names)[97:103]
> $`ZZZZZZZZZZZ/2030`
> [1] "VECTOR/188"
>
> $`ZZZZZZZZZZZ/2031`
> [1] "VECTOR/187"
>
> $`ZZZZZZZZZZZ/2032`
> [1] "VECTOR/186"
>
> $`ZZZZZZZZZZZ/2033`
> [1] "VECTOR/185"
>
> $`ZZZZZZZZZZZ/2034`
> [1] "VECTOR/183"
> [2] "VECTOR/184"
>
> $`ZZZZZZZZZZZ/2035`
> [1] "VECTOR/182"
>
> $`ZZZZZZZZZZZ/2036`
> [1] "VECTOR/181"
>
> for that I will need 2 lines in the resulting data frame.
> how do I do that?

done by a judicious use of rep.

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://www.childpsy.net/ http://iris.org.il
http://thereligionofpeace.com http://mideasttruth.com http://ffii.org
Those who can laugh at themselves will never cease to be amused.



More information about the R-help mailing list