I have run into a speed issue, and given the size of the problem it feels like there should be an easy solution. Here is the problem statement with some arbitrary numbers added.
#p,q: vector with length(q)==length(p)==10000 and length(levels(p))==3000 #y,z: vectors with length(levels(y))=length(y)==length(z)==5000 for (i in levels(p)){ q[i==p]<-z[i==y]} At first i used two for loops which was horrible, now i got rid of one but i don't know how to lose the second one. PS. I expect the solution to be available through google etc and I have searched for a solution but i did not find any usefull websites, probably because i cannot pinpoint the best search words. -- View this message in context: http://r.789695.n4.nabble.com/R-loop-problem-tp3718103p3718103.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.