I want to sort a frame by two columns, one is a numerical one and the other a factor column.
Example:
Values Size Length
1 "Small" 10
2 "Big" 6
3 "Small" 30
4 "Medium" 22
5 "Very Small" 17
6 "Small" 16
I know how to oder by two columns:
myFrame <- myFrame[order(myFrame$Size,myFrame$Length)]
However, I want to sort the column Size from "Very Small"
to "Small"
to "Medium"
to "Big"
and not merely alphabetically.
The result should look like this:
Values Size Length
5 "Very Small" 17
1 "Small" 10
3 "Small" 30
6 "Small" 16
4 "Medium" 22
2 "Big" 6
How can I sort the dataset according to the factor column?