talira

R package for type-stable vectors and building new S3 vector classes

open sourceMITfree

vctrs is an R package of vector helpers for package developers. It proposes vec_size() and vec_ptype() as alternatives to length() and class(), with a framework for size recycling and type coercion built on them; it defines size and type stability as properties functions should have; and it provides a vctr base class that makes new S3 vector classes easy to write, with methods for many base generics implemented through a few vctrs generics. Packages use it so their new vector classes work throughout the tidyverse, which is why it keeps its dependencies few. It's part of r-lib and funded by Posit.

Problems it solves

  • create a new S3 vector class in R that works with dplyr and tibble
  • combine vectors of different types in R without surprising coercions
  • write type-stable functions in an R package

Features

  • vec_size() and vec_ptype() with size recycling and type coercion
  • a vctr base class for writing new S3 vectors
  • methods for base generics through a few vctrs generics
  • few dependencies

Limitations

  • It's aimed at package developers: understanding and extending it takes some effort.1