I am trying to create a new variable in my dataframe that is the group-specific sum of a variable. For example:
df <- data.frame (group = c(1, 1, 1, 2, 2,