[ top | up ]

Length of a Vector or List

Syntax

length(x)
length(x) <- n

Description

If x is a vector or list length returns the length of x. Otherwise, length returns NA.

The second form above can be used to reset the length of a vector. If a vector is shortened, extra values are discarded and when a vector is lengthened, it is padded out to its new length with NAs.