Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

n_elements

Get the number of elements


Description

Gets the number of elements in an object.

Usage

n_elements(x)

Arguments

x

Any object.

Value

A non-negative integer of the number of elements.

Note

For atomic objects, the number of elements is the product of the dimensions, as calculated by DIM. For recursive objects, the number of elements is the sum of the number of elements of each of their atomic components.

See Also

Examples

n_elements(1:10)
n_elements(NULL)
n_elements(data.frame(x = 1:5, y = rnorm(5)))
n_elements(list(1:5, list(1:3, list(1:7))))
n_elements(var) # depends upon the length of the body

assertive.properties

Assertions to Check Properties of Variables

v0.0-4
GPL (>= 3)
Authors
Richard Cotton [aut, cre]
Initial release
2016-12-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.