I can reorder the levels of a factor using their indices like this
factor(iris$Species,levels(iris$Species)[c(3:1)])
However if I try to reorder the same factor by name, it does not work:
factor(iris$Species,levels(iris$Species)[c("virginica", "versicolor", "setosa")])
Is there a way to reorder the levels of a factor using their names?
See Question&Answers more detail:os