As this example illustrates, by
default R creates matrices by successively filling in columns. Alternatively,
the byrow = TRUE
option can be used to populate the matrix in order of the
rows.
> x = matrix(data = c(1, 2, 3, 4), nrow = 2, ncol = 2)
> x
[,1] [,2]
[1,] 1 3
[2,] 2 4
x
with a vector of (1, 2, 3, 4)
as the data parameter and set the byrow
parameter to TRUE
.