I am working on a dataset using dplyr library. I am struggling by trying to group some variables and calculating the mean and sum in one command line using "summarise_at" function.
Using the following code, I got an error.
complete.data %>%
select(A, B, C, D, E, F) %>%
group_by(A) %>%
summarise_at(vars(B, C, D), mean) %>%
summarise_at(vars(E, F, G), sum)
Moreover, I reckon that I would get a table with the following order of variables as output:
group_by (A), mean variables (B,C,D), sum variables (E,F,G)
with the related data under each column.
I would like to obtain the variables following sequence:
A(group_by) D B E C F
Could you please suggest me a way to obtain the desired result?