R merge()结果令人惊讶

时间:2015-10-16 12:00:30

标签: r

A有列a,b,c,d B有列a,b,c,e

merged = merge(A,B,by = c("a","b","c"), all.x = TRUE, sort = FALSE)
A$difference = merged$d - A$d
sum(A$difference) # <- this is unequal 0

这怎么可能? 所有列都是数值,A中的每个a,b,c值也在B

这是我的确切代码:

A = d[c("OpTyp","DeltaOffset","Size","Duration")]
B = d.aggregated[c("OpTyp","DeltaOffset","Size","mean_Duration")]
merged = merge(A,B,by = c("OpTyp","DeltaOffset","Size"), all.x = TRUE, sort = FALSE)

merged$difference = A$Duration - merged$Duration
sum(merged$difference)

0 个答案:

没有答案