I am still new to R, and I am having difficulties with the use of ifelse/if statements.
I have a dataset df with two variables progress and duration. They are both numeric and contain values from 1-100. I want to generate a new variable that should either take value "delete" or "keep", depending on the values on my two variables. I have tried the following code:
if(df$progress>86 && df$duration<60) {df$compliance <- 0} else {df$compliance <- 1}
However, it results in the following error message:
Error in if (df$progress > 86 && df$duration < 60) { : missing value where TRUE/FALSE needed
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire