I am trying some split-apply-combine methods. How do I split a data into different categories and then sort each categories on descending order of a particular column.
First I split mtcars
spmtcars <-split(mtcars, mtcars$cyl)
then if I do
sort_mtc <- spmtcars[order(mpg), ]
Error in order(mpg) : object 'mpg' not found
According to the solution here, I will have to use
sapply I am not sure how.