I need to aggregate the same values in col2 and col3, so I expect to recieve SUM in col4 and col5:
df <- data.frame("col1"="a", "col2"=c("mi", "se", "mi", "se", "ty"), 
                 "col3"=c("re", "my", "re", "my", "my"), "col4"=c(1, 2, 3, 4, 5), 
                 "col5"=c(1, 2, 3, 4, 5))
agg <- aggregate(df, by=list(df$col1, df$col2), FUN=sum)
The result is an error, though:
Error in Summary.factor(c(1L, 1L), na.rm = FALSE) : ‘sum’ not meaningful for factors
My expected output is
  col1 col2 col3 col4 col5
1    a   mi   re    4    4
2    a   se   my    6    6
3    a   ty   my    5    5
 
     
    