vctrs

Codecov test coverage Lifecycle: maturing R-CMD-check

There are three main goals to the vctrs package, each described in a vignette:

vctrs is a developer-focussed package. Understanding and extending vctrs requires some effort from developers, but should be invisible to most users. It’s our hope that having an underlying theory will mean that users can build up an accurate mental model without explicitly learning the theory. vctrs will typically be used by other packages, making it easy for them to provide new classes of S3 vectors that are supported throughout the tidyverse (and beyond). For that reason, vctrs has few dependencies.

Installation

Install vctrs from CRAN with:

install.packages("vctrs")

Alternatively, if you need the development version, install it with:

# install.packages("pak")
pak::pak("r-lib/vctrs")

Usage

library(vctrs)

# Sizes
vec_size_common(1, 1:10)
#> [1] 10
str(vec_recycle_common(1, 1:10))
#> List of 2
#>  $ : num [1:10] 1 1 1 1 1 1 1 1 1 1
#>  $ : int [1:10] 1 2 3 4 5 6 7 8 9 10

# Prototypes
vec_ptype_common(FALSE, 1L, 2.5)
#> numeric(0)
str(vec_cast_common(FALSE, 1L, 2.5))
#> List of 3
#>  $ : num 0
#>  $ : num 1
#>  $ : num 2.5