Chapter 14. Performance Enhancement: Speed and Memory

image with no caption

In computer science curricula, a common theme is the trade-off between time and space. In order to have a fast-running program, you may need to use more memory space. On the other hand, in order to conserve memory space, you might need to settle for slower code. In the R language, this trade-off is of particular interest for the following reasons:

This chapter will suggest ways that you can enhance the performance of your R code, taking into account the time/space trade-off.

What can be done to make R code faster? Here are the main tools available to you:

The first approach will be covered in this chapter, and the other approaches are covered in Chapter 15 and Chapter 16.

To optimize your R code, you need to understand R’s functional programming nature and the way R uses memory.