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) <- value

_A_r_g_u_m_e_n_t_s:

       x: an R object, for example a matrix, array or data frame.

   value: For the default method, either 'NULL' or a numeric vector
          which coerced to integer (by truncation).

_D_e_t_a_i_l_s:

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

     '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").

_V_a_l_u_e:

     For an array (and hence in particular, for a matrix) 'dim'
     retrieves the 'dim' attribute of the object.  It is 'NULL' or a
     vector of mode 'integer'.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

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

