I want to create a new column 'fgroup' based on the various combinations of values in three other columns: 'GVT', 'FOTH' and 'UNK', all three columns having either values 0 or 1. I have made this script using MUTATE
.
sysrev$fclass <- mutate(ifelse(sysrev$GVT=1 & sysrev$FOTH=0 & sysrev$UNK=0, sysrev$fgroup=1),
ifelse(sysrev$GVT=1 & sysrev$FOTH=1 & sysrev$UNK=0, sysrev$fgroup=2),
ifelse(sysrev$GVT=0 & sysrev$FOTH=1, sysrev$fgroup=3),
ifelse(sysrev$GVT=0 & sysrev$FOTH=0 & sysrev$UNK=1, sysrev$fgroup=4))
However, it returns the error message:
Error: unexpected '=' in " ifelse(sysrev$GVT="
This is probably easy but I need some advice...
Aucun commentaire:
Enregistrer un commentaire