Sum variable by group
Sum variable by group
Situation: You want to sum by group. Assuming the dataframe has at least two columns, category
and value
.
Check out original answer on stack overflow.
library(dplyr)
df %>%
group_by(category) %>%
summarise(summed_value = sum(value))
For more content on data, tech and web3 find me on Twitter.