fct_relevel not working
qutkat opened this issue · 2 comments
qutkat commented
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,
micwij commented
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")))
qutkat commented
Thankyou this works!
…________________________________
From: Micha Wijesingha Ahchige ***@***.***>
Sent: Thursday, 6 April 2023 7:19 PM
To: tidyverse/forcats ***@***.***>
Cc: Katherine Barlow ***@***.***>; Author ***@***.***>
Subject: Re: [tidyverse/forcats] fct_relevel not working (Issue #351)
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")))
—
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https://github.com/tidyverse/forcats/issues/351*issuecomment-1498748553__;Iw!!NVzLfOphnbDXSw!ANWqz6-0pwTzlC-1yHiGsn5Rw86eyjo4IvR2WK3vHpGMIa3yKEjbDAsPxO0C8M3HZKKHPzCYdM_WQF-mJMpzRmJYVpO1rmdS_urt$>, or unsubscribe<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/A66LQF52JF4FHTWFRSP7KSTW72DCHANCNFSM6AAAAAAWSABXOY__;!!NVzLfOphnbDXSw!ANWqz6-0pwTzlC-1yHiGsn5Rw86eyjo4IvR2WK3vHpGMIa3yKEjbDAsPxO0C8M3HZKKHPzCYdM_WQF-mJMpzRmJYVpO1rpRdMekb$>.
You are receiving this because you authored the thread.Message ID: ***@***.***>