You've already asked a question regarding factors, so I'm skipping that question. If you continue to have that problem, please create a new thread with a reproducible example of how you are loading the data.
Regarding the aggregate question, I think this is what you want:
> sample_data <- read.table(text = "group class amount
+ 1 1 5
+ 2 2 20
+ 1 2 3
+ 2 2 10",
+ header = TRUE)
>
> aggregate(formula = amount ~ group + class,
+ data = sample_data,
+ FUN = sum)
group class amount
1 1 1 5
2 1 2 3
3 2 2 30
This solution of course assumes that the data are in fact numbers, and not factors. The way you used mutate_if is incorrect. Check Andres previous solution, and also read the docs. You should do something like this:
df %>% mutate_if(is.factor, ~parse_number(as.character(.)))
And, if you already using dplyr, you can consider to use group_by and summarise as well.
Hope this helps.