[R] List extraction

From: chipmaney <chipmaney_at_hotmail.com>
Date: Mon, 28 Mar 2011 17:01:36 -0700 (PDT)


I have created a list of tables with the same columns but different number of row.

Example (actual list has ~200 elements):

> temp1<- data.frame(ID=c("Herb","Shrub"),stat=c(4,5),pvalue=c(.03,.04))
> temp2<- data.frame(ID=c("Herb","Shrub",
> "Tree"),stat=c(12,15,13),pvalue=c(.2,0.4,.3))
> L<-list(a=temp1,b=temp2)

> L

$a

     ID stat pvalue
1 Herb 4 0.03
2 Shrub 5 0.04

$b

     ID stat pvalue

1  Herb   12    0.2
2 Shrub   15    0.4
3  Tree   13    0.3


I want to use apply() or some other vectorized function to create a data.frame that appends/binds all rows from all elements, such that I get:

     ID stat pvalue

1  Herb    4   0.03
2 Shrub    5   0.04
3  Herb   12   0.20
4 Shrub   15   0.40
5  Tree   13   0.30

I'll forego the question of how to get the list element IDs (i.e., "a", "b") into the resulting table, unless you have the time....

thank in advance, chipper

--
View this message in context: http://r.789695.n4.nabble.com/List-extraction-tp3413374p3413374.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
Received on Tue 29 Mar 2011 - 07:07:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Mar 2011 - 07:50:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive