Core concepts of vctrs: Size, Type, and S3 Vectors
mainThe vctrs package is designed for developers building R packages, specifically focusing on three pillars:
- Size and Type Stability: It proposes
vec_size()andvec_ptype()as more robust alternatives tolength()andclass(). These functions are used within a framework for size-recycling and type-coercion. - Stability Analysis: It defines size- and type-stability as desirable properties for functions (e.g., improving upon the behavior of
c(),ifelse(), andrbind()). - S3 Vector Construction: It provides a new
vctrbase class that simplifies the creation of new S3 vectors. By implementing a few newvctrsgenerics, developers can provide robust implementations for many base R generics.
While vctrs is a developer-focused package, its goal is to provide an underlying theory that makes vector operations predictable and consistent across the tidyverse and other ecosystems.