dear R family, [a text file has been attached for better understanding] i have a list of 16 and each of of that is further subdivided into variable number of lists. So, i have a kind of list into lists phenomenon. [[1]]$'1' 1 2 3 4 5 6 7 8 9 [[1]]$'2' 1 2 3 4 5 6 7 8 9 i want to convert both these sublists into one column and then cbind it in the following way col1 col2 1 1 2 2 3 3.. 9 9 i want to the same operations on all the 16 lists. thanks in advance, elisa -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: eq.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130107/195740d2/attachment-0002.txt>
Something like do.call(cbind, lists) ? MW On Mon, Jan 7, 2013 at 4:13 PM, eliza botto <eliza_botto at hotmail.com> wrote:> > dear R family, > [a text file has been attached for better understanding] > i have a list of 16 and each of of that is further subdivided into variable number of lists. So, i have a kind of list into lists phenomenon. > [[1]]$'1' > 1 2 3 4 5 6 > 7 8 9 > > [[1]]$'2' > 1 2 3 4 5 6 > 7 8 9 > i want to convert both these sublists into one column and then cbind it in the following way > col1 col2 > 1 1 > 2 2 > 3 3.. > 9 9 > > i want to the same operations on all the 16 lists. > thanks in advance, > > elisa > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Please supply some sample data.
The easiest way to supply data is to use the dput() function. Example with
your file named "testfile":
dput(testfile)
Then copy the output and paste into your email. For large data sets, you can
just supply a representative sample. Usually,
dput(head(testfile, 100)) will be sufficient.
Simpe example:
aalist <- list(aa = c(3.0, 2.9, 2.7), bb = c(0.86, 0.76, 0.66),
cc= c(0.07, 0.04, 0.04), cc = c("a",
"b", "c"))
dput(aalist)
The attached text file was useful but actual or example data is much better.
John Kane
Kingston ON Canada
> -----Original Message-----
> From: eliza_botto at hotmail.com
> Sent: Mon, 7 Jan 2013 16:13:03 +0000
> To: r-help at r-project.org
> Subject: [R] list of lists to matrix
>
>
> dear R family,
> [a text file has been attached for better understanding]
> i have a list of 16 and each of of that is further subdivided into
> variable number of lists. So, i have a kind of list into lists
> phenomenon.
> [[1]]$'1'
> 1 2 3 4 5 6
> 7 8 9
>
> [[1]]$'2'
> 1 2 3 4 5 6
> 7 8 9
> i want to convert both these sublists into one column and then cbind it
> in the following way
> col1 col2
> 1 1
> 2 2
> 3 3..
> 9 9
>
> i want to the same operations on all the 16 lists.
> thanks in advance,
>
> elisa
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!