How to sum a variable by group in R
To sum by group in r, you can use the group_by and the summarise_at functions to get the summation by group: iris %>% # Specify data frame group_by(Species) %>% # Specify group indicator summarise_at(vars(Sepal. Length), # Specify column list(name = sum)) # Specify function # A tibble: 3 x 2 # Species name # # 1…
Answered Apr 22, 2021 · 743 Views Read answer →