I don't know why I'm struggling with this because there seem to be numerous SO answers that address this question. But here I am.
I convert a vector of 1's and 0's to a factor and label the values "yes" and "no".
fact <- factor(c(1,1,0,1,0,1),
levels=c(1,0),
labels=c("yes", "no"))
#[1] yes yes no yes no yes
#Levels: yes no
The answers to questions about converting factors back to numeric values suggest 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