There are many online resources for creating efficient R code, as well as our How to Learn R article, so we will just list the key concepts:
- Avoid using
foror lots of
ifstatements in your R code.
- Exploit R's vectorized calculations.
- Avoid using Hadleyverse functions for general data manipulation unless you have no other option. E.g., avoid
dplyr. (Much of the Hadleverse is designed for making code "easy" to read, not for making code fast.)