24.7 Vectorise

  • vectorisation means finding the existing R function that is implemented in C and most closely applies to your problem
  • Vectorised functions that apply to many scenarios
    • rowSums(), colSums(), rowMeans(), and colMeans()
    • Vectorised subsetting can lead to big improvements in speed
    • cut() and findInterval() for converting continuous variables to categorical
    • Be aware of vectorised functions like cumsum() and diff()
    • Matrix algebra is a general example of vectorisation