array(data = NA, dim, dimnames = NULL) is.array(x) as.array(x)
dim
attribute
of the array.
NA
s) are allowed.
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)
.
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]
.
# 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))