If you can do it- try a for loop and another solution to prove this to yourself. A for loop can get a little unwieldy for a novice like me to understand the code, but doable. The simpler the better, but they are not terribly slow. I have run into a couple of situations where a vectorized solution presented itself, but if not, for loops are fine with me. my $0.02
Stephen On Wed, Sep 2, 2009 at 9:25 AM, hadley wickham<h.wick...@gmail.com> wrote: >> Would like some tips on how to avoid loops as I know they are slow in R > > They are not slow. They are slower than vectorised equivalents, but > not slower than apply and friends. > > Hadley > > -- > http://had.co.nz/ > > ______________________________________________ > 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. > -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis ______________________________________________ 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.