Skip to content
Prev 305563 / 398506 Next

create new variable with ifelse? (reproducible example)

Le samedi 15 septembre 2012 ? 23:36 +0300, Niklas Fischer a ?crit :
Try:
rep_data$clo <- ifelse(rep_data$know %in% c("fairly well", "very well") &
                       rep_data$getalong %in% c(4, 5),
                        1, 0)

(Not checked, because your data is not parsed correclty by read.table
because of the spaces in the levels. Please use dput() instead.)


My two cents