I was wondering if there was an equivalent in forcats for the following example
factor(..., level = ..., ordered = TRUE)
and results.
a <- tibble(Id = 1:90, quality = rep(c("none", "poor", "fair", "average", "good", "excellent"), 15))
a$quality <- factor(a$quality, levels = c("none", "poor", "fair", "average", "good", "excellent"), ordered = TRUE)
head(a$quality)
[1] none poor fair average good excellent
Levels: none < poor < fair < average < good < excellent
This is important in the case of doing regression with ordinal categorical variable (likert scale, or bad/average/good, etc.)