sjmisc icon indicating copy to clipboard operation
sjmisc copied to clipboard

sjmisc::rec generated factors not in the expected order

Open Rick-Chen-PKU opened this issue 1 year ago • 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?

Rick-Chen-PKU avatar Oct 09 '23 14:10 Rick-Chen-PKU