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()
, andcolMeans()
- Vectorised subsetting can lead to big improvements in speed
cut()
andfindInterval()
for converting continuous variables to categorical- Be aware of vectorised functions like
cumsum()
anddiff()
- Matrix algebra is a general example of vectorisation