

   vector {base}                                R Documentation

   VVeeccttoorrss

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

        `vector' produces a vector of the given length and
        mode.

        `as.vector', a generic, attempts to coerce its argument
        into a vector of mode `mode' (the default is to coerce
        to whichever mode is most convenient).  The attributes
        of `x' are removed.

        `is.vector' returns `TRUE' if `x' is a vector (of mode
        logical, integer, real or character if not specified)
        and `FALSE' otherwise.

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

        vector(mode = "logical", length = 0)
        as.vector(x, mode = "any")
        is.vector(x, mode = "any")

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

       mode: A character string giving an atomic mode, or
             `"any"'.

     length: A non-negative integer specifying the desired
             length.

          x: An object.

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

        Note that factors are not vectors;  `is.vector' returns
        `FALSE' and `as.vector' converts to character mode.

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

        For `vector', a vector of the given length and mode.
        Logical vector elements are initialized to `FALSE',
        numeric vector elements to `0' and character vector
        elements to `""'.

   SSeeee AAllssoo::

        `c', `is.numeric', `is.list', etc.

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

        df <- data.frame(x=1:3, y=5:7)
        ## Error:
          as.vector(data.frame(x=1:3, y=5:7), mode="numeric")

        ###-- All the following are TRUE:
        is.list(df)
        ! is.vector(df)
        ! is.vector(df, mode="list")

        is.vector(list(), mode="list")
        is.vector(NULL,   mode="NULL")

