Multi-Way Arrays

DESCRIPTION:
Creates or tests for an array. Arrays are matrices and higher-dimensional generalizations of matrices.

USAGE:
array(data = NA, dim, dimnames = NULL)
is.array(x)
as.array(x)

REQUIRED ARGUMENTS:
dim:
vector giving the extent for each dimension, this is the dim attribute of the array.
x:
a vector.

OPTIONAL ARGUMENTS:
data:
vector containing the data values for the array in the normal array order: the first subscript varies most rapidly and the last subscript varies least rapidly. Missing values (NAs) are allowed.
dimnames:
list giving the dimnames for the array. This must satisfy certain criteria, see the DETAILS section below.

VALUE:
array returns an array with the same mode as data, dimensionality described by dim, and optional dimnames attribute. If data does not completely fill the array, it is repeated until the array is filled. Only the first part of data is used if it is too long.

is.array returns TRUE if x is an array object (has a dim attribute), and returns FALSE otherwise.

as.array returns x, if x is an array, otherwise a 1-dimensional array with data from x and dim attribute equal to length(x).


DETAILS:
The array class of objects are those that have an attribute dim, a vector of integers whose product equals the length of data. An array may also have an attribute dimnames. If so, this is a list of length(dim) components, each of which is either of length zero or else a vector of character strings that gives the labels corresponding to the levels of the corresponding subscript in the array. Thus, length(dimnames(x)[[i]]) must equal either 0 or dim(x)[i].

SEE ALSO:
dim , dimnames , length , list , Matrix , table , vector .

EXAMPLES:
# creates a 2 by 4 by 3 array
newarray <- array(c(1:8, 11:18, 111:118), dim = c(2,4,3))

# creates a 4 by 3 by 50 array from an external file myiris <- array(scan("irisfile"), c(4, 3, 50))