[R] long run time for loop operation & matrix fill
Roland Rau
roland.rproject at gmail.com
Fri Aug 8 16:11:56 CEST 2008
Hi,
Bert Gunter wrote:
> speedup over explicit loops. As you said, their greatest advantage is
> elegance and code readability (as functional programming, rather than
> procedural programming, constructs).
>
> As you also said, vectorizing calculations is a central theme in R that
> takes some getting used to. I know of no general prescriptions for how to do
> it; I, too, am still learning.
>
I think it takes time and experience.
To get you started, the following items might be helpful:
If I recall correctly, John Chambers dedicated some part of his book
"Programming with Data" on "the whole object view". (Again, if I
remember and interpret it correctly) he means that one should not think
element-by-element wise but thinking about "the whole object" you want
to manipulate.
Please note that he authored another book, published within the last few
weeks called "Software for Data Analysis: Programming with R". Maybe
there is also something on the subject.
"S Programming" by William Venables & Brian D. Ripley also provides very
helpful information on the topic.
Please search also on the web for "S Poetry" by Patrick Burns. It is
available for free and very informative.
Best,
Roland
More information about the R-help
mailing list