2013-05-14 79 views
2

我想在ALIST中刪除所有a數據幀 - 我該怎麼做?按名稱列出列表中的所有數據幀

alist <- list(a = data.frame(1:3), 
       b = data.frame(4:6), 
       a = data.frame(7:9)) 

(ALIST <- list(alist, alist, alist)) 
+2

很多關於這個前面的問題:http://stackoverflow.com/questions/1652522/ rbind-dataframes-in-a-list-of-lists?rq = 1 http://stackoverflow.com/questions/2851327/converting-a-list-of-data-frames-into-one-data-frame- in-r?lq = 1 http://stackoverflow.com/questions/2209258/merge-several-data-frames-into-one-data-frame-with-a-loop/2209371 http:// stac koverflow.com/questions/11934774/rbinding-a-list-of-lists-of-dataframes-based-on-nested-order?lq=1 – Thomas 2013-05-14 10:05:18

+0

這些回答都沒有幫助我。但承認在這之前我應該​​想到'lapply(ALIST,function(x)x [[「a」]])'...... – Kay 2013-05-14 11:48:52

回答

2

使用lapply於子集出你想要的元素,並用rbinddo.call名單上:

do.call("rbind",lapply(ALIST,function(x) x[["a"]])) 
    X1.3 
1 1 
2 2 
3 3 
4 1 
5 2 
6 3 
7 1 
8 2 
9 3 
相關問題