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

For an array (and hence in particular, for a matrix) they retrieve or
set the \texttt{dim} attribute of the object.

\texttt{dim} has a method for data frames, which returns the length of
the \texttt{row.names} attribute of \texttt{x} and the length of \texttt{x}
(the numbers of ``rows'' and ``columns'').\end{Details}
\begin{SeeAlso}
\texttt{\Link{ncol}}, \texttt{\Link{nrow}} and \texttt{\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}

