I am creating a set of variables all having the same levels: 0 or 1
.
However when I print them sometimes the table starts with value 0
and sometimes with 1
. I'd like to see if I can lock the order when creating them. Here is how they are created:
list = ('a','b','c')
df <- df %>% mutate_at(.vars = list, .funs = funs(yn = ifelse(. == 0,0,1)))
Also what I use for fixing the order is below:
neworder = ('0','1')
df <- arrange(transform(df, a=factor(a, levels = neworder)),a)
but I cannot combine the two procedures.