jeudi 7 juillet 2016

Ifelse statement with factors in R

I have data similar to this:

X             Y
45            45
56            34
Unspecified   Unspecified
Unspecified   23

I wanted to use an ifelse statement to compare these - giving a 1 if column X is not equal to column Y, and a 0 otherwise. I have been attempting something like this:

ifelse(data$x == data$y, 0, 1)

But to no avail. What can I do? As usual, any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire