Basic programming

For learning more about programming in R, I suggest that you check out:

Understanding the R environment

  • http://blog.obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/

Efficient R code

In a language that is compiled, such as C++, the compiler usually optimizes your code during the compilation process. R is not compiled, but interpreted. That means that one two options to write some code that produce the same output may have dramatically different runtimes.

Basic laws are:

  • Vectorize everything / i.e. avoid for loops
  • Avoid reasignment or copying of large variables
  • Prefer using in-built functions, particularly if they are compiled

For a more in-depth discussion, see here

If you have severe runtime problems, consider paralellization and or moving code to c/c++.

OO programming in R

Parallelization

Useful links:

Speed and memory issues