I have a data.frame and I need to calculate the mean per "anti-group" (i.e. per Name, below).
Name Month Rate1 Rate2
Aira 1 12 23
Aira 2 18 73
Aira 3 19 45
Ben 1 53 19
Ben 2 22 87
Ben 3 19 45
Cat 1 22 87
Cat 2 67 43
Cat 3 45 32
My desired output is like below, where the values for Rate1 and Rate2 are the means of the column's values not found in each group. Please disregard the value, I have made it up for the example. I'd prefer to do this using dplyr if possible.
Name Rate1 Rate2
Aira 38 52.2
Ben 30.5 50.5
Cat 23.8 48.7
Any help much appreciated! Thank you!
PS - Thanks to Ianthe for copying their question and their question's data but changing the question slightly. (Mean per group in a data.frame)
dplyrso did you trysummarise_all,summarise_at, etc...? - Sotosdf %>% group_by(Name) %>% summarize(Rate1=mean(Rate1), Rate2=mean(Rate2))but that calculates the mean of the Rate columns by group. I want to calculate the mean of the rate columns by everything but the group. - tubaguy