An array can be considered as a multiply subscripted collection of data entries, for example numeric. . allows simple facilities for creating and handling arrays, and in particular the special case of matrices.
A dimension vector is a vector of positive integers. If its length is k then the array is k-dimensional. The values in the dimension vector give the upper limits for each of the k subscripts. The lower limits are always 1.
A vector can be used by . as an array only if it has a dimension vector as its dim attribute. Suppose, for example, z is a vector of 1500 elements. The assignment
dim(z) <- c(3,5,100)
gives it the dim attribute that allows it to be treated as a
array.
Other functions such as matrix() and array() are available for
simpler and more natural looking assignments, as we shall see in §
.
The values in the data vector give the values in the array in the same order as they would occur in Fortran, that is `column major order', with the first subscript moving fastest and the last subscript slowest.
For example if the dimension vector for an array, say a is
c(3,4,2) then there are
entries in a and the
data vector holds them in the order a[1,1,1], a[2,1,1], ...,
a[2,4,2], a[3,4,2].