Skip to content
Prev 133869 / 398500 Next

For Loop performance

mcoyne at boninc.com wrote:
So you end up with all comparisons by:

v2m <- matrix(v2, ncol=2, byrow=TRUE)
logical_result <- (v1 == v2m[,1]) & (v1 == v2m[,2])

Now you can (1) apply vectorized statements (e.g. using ifelse()) OR (if 
1 is impossible) (2):

for (I in which(logical_result)) {
    statement_1
    statement_2
}


Uwe Ligges