\Header{integer}{Integer Vectors}
\alias{as.integer}{integer}
\methalias{as.integer.default}{integer}
\alias{is.integer}{integer}
\keyword{classes}{integer}
\begin{Description}\relax
Creates or tests for objects of type \code{"integer"}.
\end{Description}
\begin{Usage}
\begin{verbatim}
integer(length = 0)
as.integer(x, ...)
is.integer(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{Value}
\code{integer} creates a integer vector of the specified length.
Each element of the vector is equal to \code{0}.
Integer vectors exist so that data can be passed to C or Fortran code
which expects them.

\code{as.integer} attempts to coerce its argument to be of integer
type. The answer will be \code{NA} unless the coercion succeeds.
Real values larger in modulus than the largest integer are coerced to
\code{NA} (unlike S which gives the most extreme integer of the same sign).
Non-integral numeric values are truncated towards zero (i.e.,
\code{as.integer(x)} equals \code{\Link{trunc}(x)} there), and
imaginary parts of complex numbers are discarded (with a warning).
Like \code{\Link{as.vector}} it strips attributes including names.

\code{is.integer} returns \code{TRUE} or \code{FALSE} depending on
whether its argument is of integer type or not.
\code{is.integer} is generic: you can write methods to handle
specific classes of objects, see \link{InternalMethods}.
Note that factors are true for \code{is.integer} but false for
\code{\Link{is.numeric}}.
\end{Value}
\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{\Link{round}} (and \code{ceiling} and \code{floor} on that help
page) to convert to integral values.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  ## as.integer() truncates:
  x <- pi * c(-1:1,10)
  as.integer(x)
\end{ExampleCode}
\end{Examples}

