I want to sort a dataframe by a 'sum' of a group. So, I don't want the data frame to be ordered by group, but by the total amount of a group. I.e. I want to know which group is the biggest, 1 or 2 or 3 and then order the values according to that. So, say group 3 is the biggest group, then I want group 3 at the top and I want the values of group 3 in descending order.
set.seed(123)
d <- data.frame(
x = runif(90),
grp = gl(3, 30))
Thanks!