

   dim {base}                                   R Documentation

   DDiimmeennssiioonnss ooff aann OObbjjeecctt

   DDeessccrriippttiioonn::

        Retrieve or set the dimension of an object.

   UUssaaggee::

        dim(x)
        dim(x) <- values

   DDeettaaiillss::

        The functions `dim' and `dim<-' are generic.

        For an array (and hence in particular, for a matrix)
        they retrieve or set the `dim' attribute of the object.

        `dim' has a method for data frames, which returns the
        length of the `row.names' attribute of `x' and the
        length of `x' (the numbers of ``rows'' and
        ``columns'').

   SSeeee AAllssoo::

        `ncol', `nrow' and `dimnames'.

   EExxaammpplleess::

        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]

