mercredi 25 octobre 2017

Assigning a list of numbers binary class in R

I'm attempting to transform a list of numbers a binary class based on the below parameters:

IF the value is greater than 3 THEN 0

IF the value is 3 or less than 3 THEN 1

Currently I've put together the below if else command. But this is coming back as an error.

if (df$DaysOverdue[df$daysoverdue == ">3"]) {
df$DaysOverdue[df$DaysOverdue] <- 0 
}
else {
df$DaysOverdue[df$DaysOverdue] <- 1 
}

Aucun commentaire:

Enregistrer un commentaire