您如何加入而不会在r的结果表中获得NA

时间:2019-06-05 14:49:02

标签: r

我试图在r中将表联接到主表,但是联接到主表的表中的观察值均为NA。

例如,这是两个表(main_c)数据帧

species3Alpha   month   year    landing_sites   fishingunits.canoetype  sum_C_jsmycv    sum_f_jmycv
ALA 1   2019    BIG FANTE TOWN BEACH    Fante   225 12
ALA 1   2019    BIG FANTE TOWN BEACH    Kru 21  2
ALA 1   2019    Cestos Kru Beach    Kru 43  8
ALA 1   2019    FANTI  BEACH    Fante   1350    2
ALA 1   2019    GARRAWAY FANTI BEACH    Fante   1104    2
ALA 1   2019    Old  kru   town Fante   150 6
ALA 1   2019    Popo Beach  Kru 1   2
ALA 2   2019    Banjor Beach    Kru 275 2
ALA 2   2019    BIG FANTE TOWN BEACH    Fante   84  8
ALA 2   2019    Cestos Kru Beach    Kru 35.625  8
ALA 2   2019    Old  kru  town  Kru 10  2
ALA 3   2019    Garraway  fante beach   Fante   682 1
ANE 1   2019    Popo Beach  Kru 15  2
ANE 2   2019    Ceastos City Fanti Beach    Fante   3588    2
ANE 2   2019    Garraway  fanti  beach  Fante   165 2
AUR 1   2019    Cestos Kru Beach    Kru 35  2

这是(F_mycv)数据框

canoe_type  landing_sites   B_ycv   F_mycv
1   102 KRU BEACH (ROBERTSPORT) 102 1219.92
1   103 BOMOJA/KENEMA BEACH 1   11.96
1   104 SOWEE BEACH 29  346.84
1   105 TAILOR (FANTI BEACH)    53  633.88
1   106 TAILOR (KRU BEACH)  48  574.08
1   107 FUMBAH TOWN BEACH   18  215.28
1   201 TUMA TOWN BEACH 29  346.84
1   202 ROYCEVILLE BEACH    35  418.6
1   301 BANJOR BEACH    40  478.4
1   302 POINT FOUR BEACH    184 2200.64
1   303 WEST POINT BEACH    257 3073.72
1   304 BERNARD BEACH   47  562.12
1   305 KING GRAY BEACH 103 1231.88
1   306 ELWA BEACH  101 1207.96
1   307 KPEKOR BEACH    48  574.08
1   401 BEN'S TOWN  3   35.88
1   402 FLOKO TOWN BEACH    4   47.84

main_c <- main_c %>% left_join(F_mycv)

这是我得到的结果。

species3Alpha   month   year    landing_sites   fishingunits.canoetype  sum_C_jsmycv    sum_f_jmycv canoe_type  B_ycv   F_mycv
ALA 1   2019    BIG FANTE TOWN BEACH    Fante   225 12  NA  NA  NA
ALA 1   2019    BIG FANTE TOWN BEACH    Kru 21  2   NA  NA  NA
ALA 1   2019    Cestos Kru Beach    Kru 43  8   NA  NA  NA
ALA 1   2019    FANTI  BEACH    Fante   1350    2   NA  NA  NA
ALA 1   2019    GARRAWAY FANTI BEACH    Fante   1104    2   NA  NA  NA
ALA 1   2019    Old  kru   town Fante   150 6   NA  NA  NA

0 个答案:

没有答案