I have this dataframe (there are 20 more columns like class but just for the example I show a short version):
niv ID class1 class2 class3
A x 10 5 7
A y 15 3 1
A z 11 2 4
B u 17 7 3
B w 18 7 9
So I wanted to group_by(niv) and to summarise the ID column just counting it and class1, class2 and class3 columns to add up in just one command. I tried summarise_each but I can't sort out how to use it. Also the objetive would be to learn how to mix different funs in the summarise function when you have a dataframe with a lot of columns.
The summarise dataframe I need is this one:
niv n_ID sum_class1 sum_class2 sum_class3
A 3 36 10 12
B 2 35 14 12
Thanks in advance.