% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/integer64.R
\name{factor}
\alias{factor}
\alias{ordered}
\title{Factors}
\usage{
factor(
  x = character(),
  levels,
  labels = levels,
  exclude = NA,
  ordered = is.ordered(x),
  nmax = NA
)

ordered(x = character(), ...)
}
\arguments{
\item{x}{a vector of data, usually taking a small number of distinct
    values.}

\item{levels}{an optional vector of the unique values (as character strings)
    that \code{x} might have taken.  The default is the unique set of
    values taken by \code{\link[base]{as.character}(x)}, sorted into
    increasing order \emph{of \code{x}}.  Note that this set can be
    specified as smaller than \code{sort(unique(x))}.}

\item{labels}{\emph{either} an optional character vector of
    labels for the levels (in the same order as \code{levels} after
    removing those in \code{exclude}), \emph{or} a character string of
    length 1.  Duplicated values in \code{labels} can be used to map
    different values of \code{x} to the same factor level.}

\item{exclude}{a vector of values to be excluded when forming the
    set of levels.  This may be factor with the same level set as \code{x}
    or should be a \code{character}.}

\item{ordered}{logical flag to determine if the levels should be regarded
    as ordered (in the order given).}

\item{nmax}{an upper bound on the number of levels.}

\item{...}{(in \code{ordered(.)}): any of the above, apart from
    \code{ordered} itself.}
}
\value{
An object of class "factor" or "ordered".
}
\description{
The function \link{factor} is used to encode a vector as a factor.
}
\examples{
  x <- as.integer64(c(132724613L, -2143220989L, -1L, NA, 1L))
  factor(x)
  ordered(x)
}
\seealso{
\link[base:factor]{factor}
}
