R根据其他数据帧的匹配将列添加到数据帧?

时间:2020-04-15 13:31:31

标签: r match

我有2个看起来像这样的表:

table1 <- data.table("Number" = c(1,2,3,4), Type = c("A", "B", "C", "A"), "Day" = c(3,4,5,2))
table2 <- data.table("Number" = c(1,2,3,4), "Type" = c("A","B","C","A"), "Value" = c(.1, .44, .2, .6))

我想在表1中添加“值”列,它需要根据“数字”和“类型”而不只是“数字”进行匹配!终点表将如下所示:

table1 <- data.table("Number" = c(1,2,3,4), "Type" = c("A","B","C","A"), "Day" = c(3,4,5,2), "Value" = c(.1,.44,.2,.6))

我试图使用match()函数,但是如果我想同时匹配“数字”和“类型”,我不知道如何使用它。

谢谢!

0 个答案:

没有答案