Hi,
I have an easy question. I have dataframe:
df <- data.frame(
stringsAsFactors = FALSE,
a= c(1,1,1,1,1,2,2,2,2,3,3),
b = c("a","a","b","b","c","a","a","a","b","a","a"),
c= c(11,22,33,44,55,66,77,88,99,12,14)
)
and I would like to sum values in 'c' for groups of rows with the same values in 'a' and 'b' and add these sums as a new column 'd' to this dafaframe for each group of rows (sharing the same values in 'a' and 'b').
Many thanks