\Header{vector}{Vectors}
\alias{as.vector}{vector}
\alias{as.vector.factor}{vector}
\alias{is.vector}{vector}
\keyword{classes}{vector}
\begin{Usage}
\begin{verbatim}
vector(mode = "logical", length = 0)
as.vector(x, mode = "any")
is.vector(x, mode = "any")
\end{verbatim}
\end{Usage}
\begin{Description}
\texttt{vector} produces a vector of the given length and mode.  Logical
vector elements are initialized to \texttt{FALSE}, numeric vector
elements to \texttt{0} and character vector elements to \texttt{""}.

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

\texttt{is.vector} returns \texttt{TRUE} if \texttt{x} is a vector (of mode
logical, integer, real or character) and \texttt{FALSE}
otherwise.

Note that factors are \emph{not} vectors;  \texttt{is.vector} returns
\texttt{FALSE} and \texttt{as.vector} converts to character mode.\end{Description}
\begin{SeeAlso}
\texttt{\Link{c}}, \texttt{\Link{is.numeric}}, \texttt{\Link{is.list}}, etc.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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")
\end{ExampleCode}
\end{Examples}

