[R] List extraction

chipmaney chipmaney at hotmail.com
Tue Mar 29 02:01:36 CEST 2011


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.



More information about the R-help mailing list