The concatenation function, <tt>c()</tt>, with arrays.



next up previous contents
Next: Frequency tables from Up: Arrays and matrices Previous: Forming partitioned matrices.

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 the function 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).



Erik Moledor
Tue Jan 31 21:02:18 EST 1995