This is a long-lasting question, but now I really to solve this puzzle. I\'m using dplyr all the time and I think it is great to summarise variables. However, I
Instead of transposing (t
) and changing the class types, after the summarise
step, do a gather
to change it to 'long' format and then spread
it back after doing some modifications with separate
and unite
library(tidyverse)
ds %>%
group_by(group) %>%
summarise_at(vars(iq, income, math),funs(mean, sd)) %>%
gather(key, val, iq_mean:math_sd) %>%
separate(key, into = c('key1', 'key2')) %>%
unite(group, group, key2) %>%
spread(group, val)