

   length {base}                                R Documentation

   LLeennggtthh ooff aa VVeeccttoorr oorr LLiisstt

   DDeessccrriippttiioonn::

        Get or set the length of vectors (including lists).

   UUssaaggee::

        length(x)
        length(x) <- n

   AArrgguummeennttss::

          x: a vector or list.

          n: an integer.

   DDeettaaiillss::

        The replacement form 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 `NA's.

   VVaalluuee::

        If `x' is (or can be coerced to) a vector or list,
        `length' returns the length of `x'.  Otherwise,
        `length' returns `NA'.

   EExxaammpplleess::

        length(diag(4))# = 16 (4 x 4)
        length(options())# 12 or more..
        length(y ~ x1 + x2 + x3)# 3
        length(expression(x, {y <- x^2; y+2}, x^y)) # 3

