Suppose I have a vector x<-c(1,2,NA,4,5,NA) .
I apply some mythological code to this vector, which leads to another vector y<-c(1,NA,3, 4,10,NA)
Now I want to find out in which positions two vectors separate me, where I consider two NA same and one NA and not NA (for example, the second element from two examples is vectors).
In particular, for my example, I would like to get a vector holding c(2,3,5) .
In my use case, I am not happy with the vector of boolean variables, but obviously I can easily convert ( which ), so I also agree with that.
I have some solutions like:
simplediff<-x!=y nadiff<-is.na(x)!=is.na(y) which(simplediff | nadiff)
but it seems to me that I am reinventing the wheel here. Any better options?
source share