I don't know why I'm struggling with this because there seem to be numerous SO answers that address this question. But I am here.
Convert the vector 1 and 0 to a coefficient and name the values ββ"yes" and "no."
fact <- factor(c(1,1,0,1,0,1), levels=c(1,0), labels=c("yes", "no"))
Answers to questions about the conversion of factors to numerical values ββare shown by as.numeric(as.character(x)) and as.numeric(levels(x)[x] .
as.numeric(as.character(fact)) #[1] NA NA NA NA NA NA as.numeric(levels(fact))[fact] #[1] NA NA NA NA NA NA
source share