I am trying to do a simple if/else condition to either have a 1 or a -1 when R detects the word "Green" or "RED". The variable I have is called Type and it has the observations "Green" and "RED".
Here is the code I am using:
LTDWA2 <- LTDWA %>%
if(Type == "RED") {
Target = 1
} else {
Target = -1
}
The error I get is the following:
Error in if (.) Type == "RED" else { : argument is not interpretable as logical In addition: Warning message: In if (.) Type == "RED" else { : the condition has length > 1 and only the first element will be used
Can someone please help me solve this issue. Thanks.
Aucun commentaire:
Enregistrer un commentaire