\HeaderA{numeric}{Numeric Vectors}{numeric}
\aliasA{as.numeric}{numeric}{as.numeric}
\aliasA{is.numeric}{numeric}{is.numeric}
\keyword{classes}{numeric}
\keyword{attribute}{numeric}
\begin{Description}\relax
Creates or tests for objects of type \code{"numeric"}.
\end{Description}
\begin{Usage}
\begin{verbatim}
numeric(length = 0)
as.numeric(x, ...)
is.numeric(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{length}] desired length.
\item[\code{x}] object to be coerced or tested.
\item[\code{...}] further arguments passed to or from other methods.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{as.numeric} is a generic function, but methods must be
written for \code{\LinkA{as.double}{as.double}}, which it calls.

\code{is.numeric} is generic: you can write methods to handle
specific classes of objects, see \LinkA{InternalMethods}{InternalMethods}.
\end{Details}
\begin{Value}
\code{numeric} creates a real vector of the specified length.  The
elements of the vector are all equal to \code{0}.

\code{as.numeric} attempts to coerce its argument to \code{"double"}
(even if it is already \code{"integer"}).
\code{as.numeric} for factors yields the codes underlying the factor
levels, not the numeric representation of the labels, see also
\code{\LinkA{factor}{factor}}.

The default method for \code{is.numeric} returns \code{TRUE}
if its argument is of \LinkA{mode}{mode} \code{"numeric"}
(\LinkA{type}{type} \code{"double"} or type \code{"integer"}) and not a
factor, and \code{FALSE} otherwise.  That is,
\code{is.integer(x) || is.double(x)}, or
\code{(mode(x) == "numeric") \&\& !is.factor(x)}.
\end{Value}
\begin{Note}\relax
\emph{\R{} has no single precision data type.  All real numbers are
stored in double precision format}.

\code{numeric} and \code{as.numeric} are the identical to \code{double} and
\code{as.double} (unless someone defines S4 methods on one of them).
\end{Note}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{double}{double}}, \code{\LinkA{integer}{integer}}, \code{\LinkA{storage.mode}{storage.mode}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
as.numeric(c("-.1"," 2.7 ","B")) # (-0.1, 2.7, NA)  +  warning
as.numeric(factor(5:10))
\end{ExampleCode}
\end{Examples}

