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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -