I want to create a new column in R dependant on other columns in r. The format would be
new_column 0 1 0 0 1
I have three variables that the new column will be made from
comorbidity
date_of_comorbidity
DOB
I have tried using ifelse but I get an error (this is what I have tried)
newdata$newcolumn<-NA
ifelse(newdata$comorbidity1==10 &newdata$date_of_comorbidity>=DOB, newdata$newcolumn<-1,
ifelse(newdata$comorbidity1==10 &newdata$date_of_comorbidity<DOB, newdata$newcolumn<-0))
the error message is
Error in ifelse(newdata$comorbidity1==10 &newdata$date_of_comorbidity<DOB, :
argument "no" is missing
can this be fixed or is there a better way of solving my problem