[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]),

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 andreas_wittm...@gmx.dewrote: 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?

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(v10,1,0) dat -