array                  package:base                  R Documentation

_M_u_l_t_i-_w_a_y _A_r_r_a_y_s

_D_e_s_c_r_i_p_t_i_o_n:

     Creates or tests for arrays.

_U_s_a_g_e:

     array(data, dim = length(x), dimnames = NULL)
     as.array(x)
     is.array(x)

_A_r_g_u_m_e_n_t_s:

    data: a vector giving data to fill the array.

     dim: the dim attribute for the array to be reated, that is a
          vector of length one or more giving the maximal idices in
          each dimension.

dimnames: the names for the dimensions. This is a list with one
          compoent for each dimension, either NULL or a character
          vector of the length given by `dim' for that dimension.  The
          list can be names, and the names will be used as names for
          the dimensions.

       x: an R object.

_V_a_l_u_e:

     `array' returns an array with the extents specified in `dim' and
     naming information in `dimnames'.  The values in `x' are taken to
     be those in the array with the leftmost subscript moving fastest. 
     If there are too few elements in `x' to fill the array, then the
     elements in `x' are recycled.

     `as.array()' coerces its argument to be an array by attaching a
     `dim' attribute to it.  It also attaches `dimnames' if `x' has
     `names'. The sole purpose of this is to make it possible to access
     the `dim'[names] attribute at a later time.

     `is.array' returns `TRUE' or `FALSE' depending on whether its
     argument is an array (i.e., has a `dim' attribute)  or not.

_S_e_e _A_l_s_o:

     `aperm', `matrix', `dim', `dimnames'.

_E_x_a_m_p_l_e_s:

     dim(as.array(letters))
     array(1:3, c(2,4)) # recycle 1:3 "2 2/3 times"
     #     [,1] [,2] [,3] [,4]
     #[1,]    1    3    2    1
     #[2,]    2    1    3    2

