\Header{mode}{The (Storage) Mode of an Object}
\alias{mode<\Rdash}{mode}
\alias{storage.mode}{mode}
\alias{storage.mode<\Rdash}{mode}
\keyword{attribute}{mode}
\begin{Description}\relax
Get or set the type or storage mode of an object.
\end{Description}
\begin{Usage}
\begin{verbatim}
mode(x)
mode(x) <- value
storage.mode(x)
storage.mode(x) <- value
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] any \R{} object.
\item[\code{value}] a character string giving the desired (storage) mode of
the object.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Both \code{mode} and \code{storage.mode} return a character string
giving the (storage) mode of the object --- often the same --- both
relying on the output of \code{\Link{typeof}(x)}, see the example
below.

The two assignment versions are currently identical.  Both
\code{mode(x) <- newmode} and \code{storage.mode(x) <- newmode} change
the \code{mode} or \code{storage.mode} of object \code{x} to
\code{newmode}.

As storage mode \code{"single"} is only a pseudo-mode in \R, it will
not be reported by \code{mode} or \code{storage.mode}: use
\code{attr(object, "Csingle")} to examine this. However, the
assignment versions can be used to set the mode to \code{"single"},
which sets the real mode to \code{"double"} and the \code{"Csingle"}
attribute to \code{TRUE}. Setting any other mode will remove this
attribute.

Note (in the examples below) that some \code{\Link{call}}s have mode
\code{"("} which is S compatible.
\end{Details}
\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{typeof}} for the R-internal \dQuote{mode},
\code{\Link{attributes}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
sapply(options(),mode)

cex3 <- c("NULL","1","1:1","1i","list(1)","data.frame(x=1)", "pairlist(pi)",
  "c", "lm", "formals(lm)[[1]]",  "formals(lm)[[2]]",
  "y~x","expression((1))[[1]]", "(y~x)[[1]]", "expression(x <- pi)[[1]][[1]]")
lex3 <- sapply(cex3, function(x) eval(parse(text=x)))
mex3 <- t(sapply(lex3, function(x) c(typeof(x), storage.mode(x), mode(x))))
dimnames(mex3) <- list(cex3, c("typeof(.)","storage.mode(.)","mode(.)"))
mex3

## This also makes a local copy of 'pi':
storage.mode(pi) <- "complex"
storage.mode(pi)
rm(pi)
\end{ExampleCode}
\end{Examples}

