[R] unlist & dataframes
David Freedman
3.14david at gmail.com
Thu Nov 6 12:02:37 CET 2008
try
newdata=do.call(rbind,l)
David Freedman, Atlanta
Naira wrote:
>
> Dear all,
>
> I would like to know whether it is possible to unlist elements and keep
> the original format of the data.
> To make it more clear, let me give an exemple:
> I have a list l of dataframes that I created with apply but which looks
> like this:
>
> x1=data.frame(Name=LETTERS[1:2],Age=1:2)
> x2=data.frame(Name=LETTERS[3:4],Age=3:4)
> l=list(x1,x2)
> l
> [[1]]
> Name Age
> 1 A 1
> 2 B 2
>
> [[2]]
> Name Age
> 1 C 3
> 2 D 4
>
> I would like to unlist l to create a dataframe with 2 columns and 4 rows
> but keeping the format of Name (character) and Age (numeric).
>
> Now when I unlist l, I obtain :
>
> unlist(l)
> Name1 Name2 Age1 Age2 Name1 Name2 Age1 Age2
> 1 2 1 2 1 2 3 4
>
> Is there a way to at least obtain something like
> A 1 B 2 C 3 D 4 as result from the unlist??
>
> Thanks a lot for your replies
> Naira
>
>
>
-----
David Freedman
Atlanta
--
View this message in context: http://www.nabble.com/unlist---dataframes-tp20358993p20359063.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list