An array can be considered as a multiply subscripted collection of data entries. This section provides details on the construction and manipulation of arrays.
The concatenation function, c(), with arrays
It should be noted that whereas cbind()
and rbind()
are
concatenation functions that respect dim
attributes, the basic
c()
function does not, but rather clears numeric objects of all
dim
and dimnames
attributes. This is occasionally useful
in its own right.
The official way to coerce an array back to a simple vector object is to
use as.vector()
> vec <- as.vector(X)
However a similar result can be achieved by using c()
with just
one argument, simply for this side-effect:
> vec <- c(X)
There are slight differences between the two, but ultimately the choice between them is largely a matter of style (with the former being preferable).