Flatten (i.e., collapse) a matrix or array to one dimension.
Usage
flatten(x, across = c("rows", "columns"))Arguments
- x
- A matrix. 
- across
- Character string specifying whether to flatten the matrix across - "rows"(default) or- "columns". This option is ignored for multi-way arrays.
See also
mat.
Examples
m <- mat("2, 4, 6, 8; 10, 12, 14, 16")
flatten(m)
#> [1]  2  4  6  8 10 12 14 16
flatten(m, across = "columns")
#> [1]  2 10  4 12  6 14  8 16