What is happening in the first line of code and why does the result differ from the two next results?
library(tidyverse)
library(magrittr)
data.frame(A=c(2,2),B=c(1,1)) %>%
summarise(A = sum(A),B = sum(B), D=sum(A)-sum(B))
yields D=0
data.frame(A=c(2,2),B=c(1,1)) %>%
summarise(A = sum(A),B = sum(B), D=sum(A-B) )
yields in D=2
data.frame(A=c(2,2),B=c(1,1)) %>%
summarise(sum_A = sum(A),sum_B = sum(B), D=sum(A)-sum(B))
yields in D=2.
I can't seem to come up with an explanation to how the D=0 can be a result of such an operation. How can D=0
be a sensible result?