数据框合并R

时间:2019-03-20 16:44:14

标签: r

我想将R中的这两个DF /表合并在一起,以得到表3中两个列的完整数据视图,如表3所示。NA所得列中的值可以替换为0。

TABLE 1:
    ID  ACCT_NAME   YEAR    MONTH   POS_COUNT
    1   Customer1   2018    Apr           5
    1   Customer1   2018    Aug           1
    1   Customer1   2018    Dec           8
    2   Customer2   2018    Aug           1
    2   Customer2   2018    Dec           1
    2   Customer2   2018    Jun           1
    3   Customer3   2018    Aug           1
    3   Customer3   2018    Dec           1
    3   Customer4   2018    Jul           1
    3   Customer4   2018    Nov           1

TABLE 2:
    ID  ACCT_NAME   YEAR    MONTH   DOS_COUNT
    1   Customer1   2018    Apr         6
    1   Customer1   2018    Sep         4
    1   Customer1   2018    Dec         4 
    1   Customer2   2018    Jul         4
    1   Customer2   2018    May         3
    1   Customer2   2018    Dec         6
    2   Customer2   2018    Jul         7
    2   Customer2   2018    Dec         7
    2   Customer2   2018    Jun         2
    3   Customer4   2018    Aug         8
    3   Customer4   2018    Dec         1
    3   Customer5   2018    Mar         1
    3   Customer5   2018    Nov         4



TABLE 3:
    ID  ACCT_NAME   YEAR    MONTH   POS_COUNT  DOS COUNT

0 个答案:

没有答案