Re: [R] Replacing double loop by apply

2010-05-14 Thread Andreas Wittmann
Dear Henrique Dallazuanna, thank you very much, this really helped me. by the way, do you thinks it is also possible to do the following loop in R? thanks and best regards Andreas v1 <- rnorm(10) v2 <- v1+rnorm(10) v3 <- v2+rnorm(10) v4 <- rnorm(10) y <- ifelse(v1<0,1,0) dat <- data.frame(v

Re: [R] Replacing double loop by apply

2010-05-14 Thread Henrique Dallazuanna
Try this: mapply(function(x, y)x[match(x, y)], m2, m1) On Fri, May 14, 2010 at 9:23 AM, Andreas Wittmann wrote: > Dear R-users, > > after trying and searching a long time i have the following question. > is it possible to replace to following double loop by some apply calls? > >

[R] Replacing double loop by apply

2010-05-14 Thread Andreas Wittmann
Dear R-users, after trying and searching a long time i have the following question. is it possible to replace to following double loop by some apply calls? ### m1 <- data.frame(v1=factor(letters[1:5]), v2=factor