I would like to add overall summary rows while also calculating summaries by group using dplyr. I have found various questions asking how to do this, e.g. here, here, and he
maybe that works:
library(dplyr) mtcars %>% # convert cyl column as.character mutate_at("cyl",as.character) %>% # add a copy of the origina data with cyl column = 'TOTAL' bind_rows(mutate(mtcars, cyl="total")) %>% group_by(cyl) %>% summarise_all(sum)