Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R merge()得到了令人惊讶的结果_R - Fatal编程技术网

R merge()得到了令人惊讶的结果

R merge()得到了令人惊讶的结果,r,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 什么是d和d.聚合对象?你能提供A和B的示例数据吗?这讨论了如何询问有关SO的问题:请重新阅读提供的链接@G.Grothendieck,可能还有此链接,具体针对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

什么是d和d.聚合对象?你能提供A和B的示例数据吗?这讨论了如何询问有关SO的问题:请重新阅读提供的链接@G.Grothendieck,可能还有此链接,具体针对R:。你的问题仍然无法重现,因为我们不知道d中是什么或d中是什么。
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)