合并R中的2个列表

时间:2018-09-28 16:36:46

标签: r list dataframe merge

我在R中有2个列表,列表名称如下:

str(total_delta_final[[1]])
List of 4
 $ sector1_T02 :'data.frame':   24 obs. of  3 variables:
  ..$ DeltaF_1: num [1:24] 0.737 0.737 0.693 0.738 0.738 ...
  ..$ DeltaF_2: num [1:24] 0.24 0.24 0.279 0.239 0.239 ...
  ..$ DeltaF_3: num [1:24] 0.0233 0.0233 0.0275 0.0232 0.0232 ...
 $ sector2_T03 :'data.frame':   24 obs. of  3 variables:
  ..$ DeltaF_1: num [1:24] 0.582 0.582 0.568 0.69 0.69 ...
  ..$ DeltaF_2: num [1:24] 0.377 0.377 0.39 0.282 0.282 ...
  ..$ DeltaF_3: num [1:24] 0.0406 0.0406 0.0426 0.0278 0.0278 ...
 $ sector3_T03 :'data.frame':   24 obs. of  3 variables:
  ..$ DeltaF_1: num [1:24] 0.607 0.607 0.495 0.409 0.375 ...
  ..$ DeltaF_2: num [1:24] 0.356 0.356 0.451 0.519 0.544 ...
  ..$ DeltaF_3: num [1:24] 0.0373 0.0373 0.0541 0.072 0.0809 ...
 $ sector12_T02:'data.frame':   24 obs. of  3 variables:
  ..$ DeltaF_1: num [1:24] 0.743 0.743 0.758 0.689 0.705 ...
  ..$ DeltaF_2: num [1:24] 0.234 0.234 0.22 0.283 0.269 ...
  ..$ DeltaF_3: num [1:24] 0.0226 0.0226 0.0213 0.028 0.0263 ...


> str(total_TI_final[[1]])
List of 4
 $ sector1_T02 :'data.frame':   24 obs. of  3 variables:
  ..$ I_1: num [1:24] NA 0.0756 0.083 0.0799 0.0799 ...
  ..$ I_2: num [1:24] 0.122 NA 0.163 0.172 0.172 ...
  ..$ I_3: num [1:24] 0.212 0.211 NA 0.266 0.273 ...
 $ sector2_T03 :'data.frame':   24 obs. of  3 variables:
  ..$ I_1: num [1:24] NA 0.0986 0.1013 0.1011 0.101 ...
  ..$ I_2: num [1:24] 0.15 NA 0.184 0.211 0.211 ...
  ..$ I_3: num [1:24] 0.249 0.249 NA 0.331 0.337 ...
 $ sector3_T03 :'data.frame':   24 obs. of  3 variables:
  ..$ I_1: num [1:24] NA 0.119 0.115 0.113 0.105 ...
  ..$ I_2: num [1:24] 0.193 NA 0.2 0.193 0.177 ...
  ..$ I_3: num [1:24] 0.323 0.323 NA 0.277 0.256 ...
 $ sector12_T02:'data.frame':   24 obs. of  3 variables:
  ..$ I_1: num [1:24] NA 0.0825 0.0681 0.0723 0.0706 ...
  ..$ I_2: num [1:24] 0.138 NA 0.146 0.145 0.144 ...
  ..$ I_3: num [1:24] 0.24 0.24 NA 0.22 0.226 ...

如何合并这两个列表,使最终输出看起来像total_TI_final[[1]][1],第二个列表total_delta_final[[1]][1],然后是total_TI_final[[1]][2]total_delta_final[[1]][2],依此类推...

1 个答案:

答案 0 :(得分:2)

我们可以使用primary_key=True

Map