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)