编辑
我有两个不同长度的数据框:
kframe <- data.frame(One=c("NO123","NO234", "NO345", "NO432"),Two=c("NAME1","NAME2","NAME3","NAME4"), Three=c(1,2,3,4))
lframe <- data.frame(One=c("NO123","NO587", "NO345"),Two=c("N1","N2","N2"), Three=c(2,3,4))
想检查lframe$One[x]
(with x=1:nrow(lframe)
) 中的值是否存在于 中kframe$One
,如果为真则替换 中的值lframe$Two[x]
,否则什么也不做。
这个怎么做?
编辑:
或者,换一种说法:如果为真,则将值添加到 $Three...
预期结果:
框架:
One Two Three
1 NO123 NAME1 3
2 NO587 N2 3
3 NO345 NAME3 7