

dim {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.

     `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_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]

