如何通过列表中数据框的名称来组合很多数据框

时间:2019-05-07 22:40:48

标签: r list dataframe

我有这两个数据帧(现实生活中有680个数据帧):

DF1 <- data.frame(City = c("New York", "New York", "New York", "New York", "New York"), Income = c("1","2","3","4","5"), Amount = c(0, 13291.23678, 0,0,0))
DF2 <- data.frame(City = c("Dallas", "Dallas","Dallas","Dallas","Dallas"), Income = c("1","2","3","4","5"),Amount = c(0, 65666.2885,106896.3682,69949.63342,35549.94405))

我必须通过行将这两个数据框组合起来,但是我在列表中有数据框的名称。

我的预期结果是使用该列表合并这些数据框,如下所示:

DF<- data.frame(rbind(DFNames))

并生成此数据帧:

       City Income    Amount
   New York      1      0.00
   New York      2  13291.24
   New York      3      0.00
   New York      4      0.00
   New York      5      0.00
     Dallas      1      0.00
     Dallas      2  65666.29
     Dallas      3 106896.37
     Dallas      4  69949.63
     Dallas      5  35549.94

0 个答案:

没有答案