I have a data frame with two column:
x <- c(1, 2, 3, 4, NA, 5, 6)
y <- c(1, 2, 4, 5, 0, 5, 6)
my.df <- data.frame(x, y)
I want to keep only the rows where x != y.
What I did is this:
my.df <- subset(my.df, x != y)
What I expected was:
x y
3 4
4 5
NA 0
What I got was
x y
3 4
4 5
This is because, by a strange convention, NA != 0 is NA.
I really want to keep the NA in the subset because I'm looking for the differences between the columns.
How to achieve this?