假设我有2个dataframes。我想从每个数据帧中只选择一行,让我们说行业c3,并将它们放在另一个data.frame,df3中。采取从n个dataframes一行,并创建所采取的行一个新的数据帧,R
df1 = data.frame(Industries = c("c1", "c2", "c3", "c4", "c5"), Exports = c(100, 40, 30, 10, 50), Imports =c(90,50,25,15,50))
df2 = data.frame(Industries = c("c1", "c2", "c3", "c4", "c5"), Exports = c(20, 90, 10, 30, 60), Imports =c(40,30,25,55,40))
df1
Industries Exports Imports
1 c1 100 90
2 c2 40 50
3 c3 30 25
4 c4 10 15
5 c5 50 50
df2
Industries Exports Imports
1 c1 20 40
2 c2 90 30
3 c3 10 25
4 c4 30 55
5 c5 60 40
在我真实的数据我有16个不同的dataframes,所以如果可能的代码应该允许把16行从另一个16个dataframes,将创建。
'做行.call(rbind,lapply(list(df1,df2),subset,Industries ==“c3”))'? – Psidom