python - Converting Yes and No to 0 and 1 in R -
how convert categorical value (yes/no) numeric value (0/1) in data set of 20 variables , 3144 observations in r?
in r can either do
df1[] <- +(df1=="yes") or
df1[] <- lapply(df1, function(x) as.integer(x=="yes")) note: if "yes" should 0 , "no" 1, replace df1=="no" , x=="no" in post.
Comments
Post a Comment