strengejacke / sjmisc

Data transformation and utility functions for R

Home Page:https://strengejacke.github.io/sjmisc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sjmisc::rec generated factors not in the expected order

Rick-Chen-PKU opened this issue · comments

d = tibble(x = c(1,2,3,4))
d <- d %>% mutate(x = rec(x, rec="1=YES;2=No;3=Me;4=He", as.num = F, append = T) )
d$x

Hi, I did a simple test as shown in the code above. I want the order of the generated factors to be "Yes No Me He", but the order of the above result is "He Me No YES". Is there any parameter that can be utilized to make the factor in the desired order?