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 = NA, dim = length(data), dimnames = NULL)
     as.array(x, ...)
     is.array(x)

_A_r_g_u_m_e_n_t_s:

    data: a vector (including a list) giving data to fill the array.

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

dimnames: either 'NULL' or the names for the dimensions. This is a list
          with one component for each dimension, either 'NULL' or a
          character vector of the length given by 'dim' for that
          dimension.  The list can be named, and the list names will be
          used as names for the dimensions.  If the list is shorter
          than the number of dimensions, it is extended by 'NULL's to
          the length required

       x: an R object.

     ...: additional arguments to be passed to or from methods.

_V_a_l_u_e:

     'array' returns an array with the extents specified in 'dim' and
     naming information in 'dimnames'.  The values in 'data' are taken
     to be those in the array with the leftmost subscript moving
     fastest.  If there are too few elements in 'data' to fill the
     array, then the elements in 'data' are recycled.  If 'data' has
     length zero, 'NA' of an appropriate type is used for atomic
     vectors ('0' for raw vectors) and 'NULL' for lists.

     'as.array' is a generic function for coercing to arrays.  The
     default method does so 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 of positive
     length) or not.  It is generic: you can write methods to handle
     specific classes of objects, see InternalMethods.

_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:

     '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

