On 01-02-2012, at 17:32, Chris82 wrote:

> Thanks to both.
> 
> This is just a simple example. In real I have two vectors with different
> lengths. 
> The code consists of two for loops for r and z. The main problem is the
> computational time, so I try to stop the loop if w is TRUE for the first
> time.
> 

Maybe this helps:

z <- c(0,1,2,3,4,5,6,7,8,9)
r <- c(3,7)

fun1 <- function(r, z) sapply(r,function(x) which(x == z))
fun1(r,z)

Berend

______________________________________________
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.

Reply via email to