Re: [R] indices of mismatch element in two vector with missing values

2015-07-29 Thread baccts
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

[R] indices of mismatch element in two vector with missing values

2015-07-28 Thread baccts
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

[R] sequential sum

2012-02-14 Thread baccts
Dear R users, I am trying to sum number that exist in another vector up to i, then increment i and repeat. Sorry. It's hard to explain but basically I am trying to do the following: test <- c(1,2,3,4); test2 <- c(3,5,6,7,2,8,8,4,4); test3 <- c(10,20,30,40); tmp <- 0; for (i in 1:length(test)){ tmp