I have a categorical data set that looks similar to:
A < -data.frame(animal = c(\"cat\",\"cat\",\"cat\",\"dog\",\"dog\",\"dog\",\"elephant\",\"elephant\",
You can also use match - you do not alter column class neither do a factor transformation.
animalOrder = c("dog", "elephant","cat")
colorOrder = c("green", "blue", "red")
A[ order(match(A$animal, animalOrder), match(A$color, colorOrder)), ]
animal color
6 dog green
4 dog blue
5 dog red
9 elephant green
7 elephant blue
8 elephant red
3 cat green
1 cat blue
2 cat red