I have to apply condition to two columns in order to get a new column with 1 and 0's, I want the NA's in column1 to be retained as NA's in the new column. How do I do it in R?
This is code
df$newcolumn <- ifelse(((df$col1 %in% ("eat")) |
(df$col2 %in% ("yes"))), 1, 0)
Aucun commentaire:
Enregistrer un commentaire