【发布时间】:2018-03-21 21:08:26
【问题描述】:
我有两个数据框
db1 喜欢:
date.prix;var1;var2
2012-10-02;pluf;plof
2012-12-11;pam;pim
2013-05-17;plop;plip
...
db2 喜欢:
date.de.cotation;var3;var4
2012-10-02;tutu;toto
2012-10-02;ting;tong
2013-05-17;gui;guou
...
连接是 date.prix = date.de.cotation
我想要类似的东西:
date.prix;var1;var2;var3;var4
2012-10-02;pluf;plof;tutu;toto
2012-12-11;pam;pim;NA;NA
2013-05-17;plop;plip;gui;guou
所以:
- 如果 db2 中有重复项,我想要第一个的值
- 如果 db2 中没有日期值,我想要 NAs
【问题讨论】:
-
从
db2中删除重复项并使用all.x = T将db1与db2合并。
标签: r join merge duplicates