Arrays in R
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).