rray_elems() computes the number of individual elements in an array. It generally computes the same thing as length(), but has a more predictable name.

rray_elems(x)

Arguments

x

A vector, matrix, array or rray.

Value

A single integer. The number of elements in x.

Examples

rray_elems(1:5)
#> [1] 5
rray_elems(matrix(1, 2, 2))
#> [1] 4
# It is different from `vec_size()`, # which only returns the number of # observations library(vctrs) vec_size(matrix(1, 2, 2))
#> [1] 2