strengejacke/sjmisc

sjmisc::rec generated factors not in the expected order

Rick-Chen-PKU opened this issue · 0 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?