This is material from a 1 1/2 hour workshop on making R code efficient.
This covers
- bad idioms,
- good idioms,
- vectorization,
- profiling,
- changing functions based on profiling
- counting the number of calls
- examining the call stack to determine what functions call expensive functions
- using C/C++ code,
- creating R packages with C code
The step-by-step profiling and refining code is described in ExampleCode
We'd love to see R code you care about that runs slowly (not as fast as you want) as a) we'd like to help, and b) we are working on making R smarter so that it runs code faster. We'll help you and you'll help the entire R community. Get in touch with us (datascience@ucdavis.edu) or come to office hours (see dsi.ucdavis.edu).