My question is simple. I've a dataset like this one:
observed predicted probability result2
1 Head-up Grazing 0.2727273 FALSE
2 Head-up Grazing 0.7272727 TRUE
3 Head-up Grazing 0.7272727 TRUE
4 Head-up Grazing 0.5454545 TRUE
5 Head-up Grazing 0.7272727 TRUE
6 Head-up Grazing 0.4545455 FALSE
7 Head-up Vigilance 0.3636364 FALSE
8 Head-up Grazing 0.3636364 FALSE
9 Head-up Vigilance 0.3636364 FALSE
10 Unknown Grazing 0.3636364 FALSE
11 Moving Head-up 0.4545455 FALSE
12 Moving Head-up 0.3636364 FALSE
Where I've successfully created column results2 by using the ifelse function like so:
table$result1<-ifelse(table$probability>0.5,"TRUE","FALSE")
However, I'm trying to use the same function to create column result1, which would be:
table$result1<-ifelse(table$observed=table$predicted, "POSITIVE", "NEGATIVE")`.
I'm getting the error Error: unexpected '=' in table$result1<-ifelse(table$observed=
Indeed, I'd like to have "POSITIVE" if the word on column observed matches the one on the column predicted of the same row, and "NEGATIVE" if vice versa..
Any ideas? Any help is appreciated!
Aucun commentaire:
Enregistrer un commentaire