Thank you everyone for taking the time to reply.
Thanks Martin and Hervé for your solutions.
Now I just need to remember to check for NA match.
--
View this message in context:
http://r.789695.n4.nabble.com/indices-of-mismatch-element-in-two-vector-with-missing-values-tp4710497p4710518.html
Se
works:
> x == y & is.na(x) == is.na(y)
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> seq(x)[!(x == y & is.na(x) == is.na(y))]
[1] 1 2 3 4 5 6 7 8
>
Martin Maechler
ETH Zurich
>> -Original Message-
>> From: R-help [mailto:r-help-boun..
...@r-project.org] On Behalf Of baccts
Sent: Wednesday, 29 July 2015 8:26 a.m.
To: r-help@r-project.org
Subject: [R] indices of mismatch element in two vector with missing values
How would you return the index where two vectors differs if they may contain
missing (NA) values?
For example:
test1 &
Hi,
On 07/28/2015 01:25 PM, baccts wrote:
How would you return the index where two vectors differs if they may contain
missing (NA) values?
For example:
test1 <- c("1","2",NA);
test2 <- c("1","2","3");
which(test1!=test2) does not return 3!
which(test1 != test2 | is.na(test1) != is.na(test2))
mismatch element in two vector with missing values
How would you return the index where two vectors differs if they may contain
missing (NA) values?
For example:
test1 <- c("1","2",NA);
test2 <- c("1","2","3");
which(test1!=test2) does not ret
How would you return the index where two vectors differs if they may contain
missing (NA) values?
For example:
test1 <- c("1","2",NA);
test2 <- c("1","2","3");
which(test1!=test2) does not return 3!
Thanks in advance.
--
View this message in context:
http://r.789695.n4.nabble.com/indices-of
6 matches
Mail list logo