dim                   package:base                   R Documentation

_D_i_m_e_n_s_i_o_n_s _o_f _a_n _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     Retrieve or set the dimension of an object.

_U_s_a_g_e:

     dim(x)
     dim(x) <- values

_D_e_t_a_i_l_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.  It is always `integer'
     or `NULL'.

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

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_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]

