您好,我正在尝试通过仅定义哪个因子级别应该是第一个来重新排序因子级别。
library(plyr)
library(dplyr)
wrong <-iris %>% mutate(Species = reorder(Species,desc(Species)))
levels(iris.re$Species)
我想使用 mutate 来定义 f.e.
versicolor
为第一个因子级别并对其他因子级别进行排序。
我知道还有其他选项可以做到这一点,但我想使用 plyr
/dplyr
。
谢谢
尝试重新升级:
iris <- iris %>% mutate(Species=relevel(Species,ref="versicolor"))