• vec_dim_n() gives the dimensionality (i.e. number of dimensions)

• vec_dim() returns the size of each dimension

vec_dim(x)

vec_dim_n(x)

## Arguments

x A vector

## Details

Unlike base R, we treat vectors with NULL dimensions as 1d. This simplifies the type system by eliding a special case. Compared to base R equivalent, vec_dim() returns length(), not NULL, when x is 1d.

## Examples

# Compared to base R
x <- 1:5
dim(x)#> NULLvec_dim(x)#> [1] 5