array(data = NA, dim = length(data), dimnames = NULL) as.array(x, ...) is.array(x)
NULLor the names for the dimensions. This must a list (or it will be ignored) with one component for each dimension, either
NULLor a character vector of the length given by
dimfor 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
NULLs to the length required.
arrayreturns an array with the extents specified in
dimand naming information in
dimnames. The values in
dataare taken to be those in the array with the leftmost subscript moving fastest. If there are too few elements in
datato fill the array, then the elements in
dataare recycled. If
datahas length zero,
NAof an appropriate type is used for atomic vectors (
0for raw vectors) and
arraydoes not currently remove any attributes left by
as.vectorfrom a classed list
data, so can return a list array with a class attribute.
as.arrayis a generic function for coercing to arrays. The default method does so by attaching a
dimattribute to it. It also attaches
names. The sole purpose of this is to make it possible to access the
dim[names]attribute at a later time.
FALSEdepending on whether its argument is an array (i.e., has a
dimattribute of positive length) or not. It is generic: you can write methods to handle specific classes of objects, see InternalMethods.
"dim") and optionally names for those dimensions (attribute
A two-dimensional array is the same thing as a
One-dimensional arrays often look like vectors, but may be handled
differently by some functions:
str does distinguish
them in recent versions of R.
"dim" attribute is an integer vector of length one or more
containing non-negative values: the product of the values must match
the length of the array.
"dimnames" attribute is optional: if present it is a list
with one component for each dimension, either
NULL or a
character vector of the length given by the element of the
"dim" attribute for that dimension.
is.array is a primitive function.
For a list array, the
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