domains / families / research / r-performance
r-performance
separate
R performance best practices including profiling, benchmarking, vctrs, and optimization strategies. Use when optimizing R code.
When to use
- **Type stability** - Predictable output types regardless of input values
- **Size stability** - Predictable output sizes from input sizes
- **Consistent coercion rules** - Single set of rules applied everywhere
- **Robust class design** - Proper S3 vector infrastructure
- **Simple operations** - `vec_c(1, 2)` vs `c(1, 2)` for basic atomic vectors
- **One-off scripts** - Type safety less critical than speed
- **Small vectors** - Overhead may outweigh benefits
- **Package functions** - Type stability prevents expensive re-computation
When not to use
- simple functions with known issues
- one-off scripts where speed matters most
- simple operations where base R is sufficient
- memory extremely constrained environments
- teaching/learning contexts
- no dependencies allowed environments
Skill page
Source