Thanks to Berend and the others, I've found a solution which works fine for my problem.
I have not only 2 vectors, but also 4. Question is, if q1 and q2 is equal to w1 and w2. The computational time is very short, also for large data. q1 <- c(9,5,1,5) q2 <- c(9,2,1,5) w1 <- c(9,4,4,4,5) w1 <- c(9,4,4,4,5) v <- vector() for (i in 1:(length(q1))){ v[i] <- any((q1[i] == w1) & (q2[i] == w2)) } best regards -- View this message in context: http://r.789695.n4.nabble.com/While-loop-working-with-TRUE-FALSE-tp4348340p4351214.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.