tidyverse/forcats

fct_relevel not working

qutkat opened this issue · 2 comments

Hello,

I tried using the following code to reorder a variable. i didn't receive any error message but the factors were still printing out in alphabetical order instead of the order I specified.

test = dass %>% mutate(depression_rating = fct_relevel(depression_rating, "normal", "mild", "moderate", "severe", "extremely_severe"))

Thanks,

I think it should work if you wrap the new levels in a character vector:

test = dass %>% mutate(depression_rating = fct_relevel(depression_rating, c("normal", "mild", "moderate", "severe", "extremely_severe")))