Is it possible to summarise big number of columns, without writing all their names?
My example: I have a dataframe (dt) with one categorical column and a lot of numeric colunms:
Cat num1 num2 num3 ... num50
a 56 59 67 ... 89
a 46 66 27 ... 59
b 15 9 75 ... 43
b 45 29 35 ... 93
I make the following operation:
dt %>% group_by(Cat) %>% summarize(num1 = sum(num1), num2 = sum(num2), ... num50= sum(num50))
But writing all the 50 column names takes too long time! Can I write this summarize expression shorter? I tried this variant, but it doesn't work:
dt %>%
group_by(Cat) %>%
summarize(num1:num50 = sum(c(num1:num50)))
Help me, please, how to write it laconically using dplyr of data.table (or other libraries).