\HeaderA{data.class}{Object Classes}{data.class}
\keyword{classes}{data.class}
\keyword{methods}{data.class}
\begin{Description}\relax
Determine the class of an arbitrary \R{} object.
\end{Description}
\begin{Usage}
\begin{verbatim}
data.class(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an \R{} object.
\end{ldescription}
\end{Arguments}
\begin{Value}
character string giving the \emph{class} of \code{x}.

The class is the (first element) of the \code{\LinkA{class}{class}}
attribute if this is non-\code{NULL}, or inferred from the object's
\code{dim} attribute if this is non-\code{NULL}, or \code{mode(x)}.

Simply speaking, \code{data.class(x)} returns what is typically useful
for method dispatching.  (Or, what the basic creator functions already
and maybe eventually all will attach as a class attribute.)
\end{Value}
\begin{Note}\relax
For compatibility reasons, there is one exception to the rule above:
When \code{x} is \code{\LinkA{integer}{integer}}, the result of
\code{data.class(x)} is \code{"numeric"} even when \code{x} is classed.
\end{Note}
\begin{SeeAlso}\relax
\code{\LinkA{class}{class}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- LETTERS
data.class(factor(x))                 # has a class attribute
data.class(matrix(x, ncol = 13))      # has a dim attribute
data.class(list(x))                   # the same as mode(x)
data.class(x)                         # the same as mode(x)

stopifnot(data.class(1:2) == "numeric")# compatibility "rule"
\end{ExampleCode}
\end{Examples}

