\Header{dim}{Dimensions of an Object}
\methalias{dim.data.frame}{dim}
\alias{dim<\Rdash}{dim}
\keyword{array}{dim}
\begin{Description}\relax
Retrieve or set the dimension of an object.\end{Description}
\begin{Usage}
\begin{verbatim}
dim(x)
dim(x) <- values
\end{verbatim}
\end{Usage}
\begin{Details}\relax
The functions \code{dim} and \code{dim<-} are generic.

For an array (and hence in particular, for a matrix) they retrieve or
set the \code{dim} attribute of the object.  It is always
\code{\Link{integer}} or \code{\Link{NULL}}.

\code{dim} has a method for \code{\Link{data.frame}}s, which returns
the length of the \code{row.names} attribute of \code{x} and the
length of \code{x} (the numbers of ``rows'' and ``columns'').\end{Details}
\begin{SeeAlso}\relax
\code{\Link{ncol}}, \code{\Link{nrow}} and \code{\Link{dimnames}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- 1:12 ; dim(x) <- c(3,4)
x

# simple versions of nrow and ncol could be defined as follows
nrow0 <- function(x) dim(x)[1]
ncol0 <- function(x) dim(x)[2]
\end{ExampleCode}
\end{Examples}

