Learn R Programming

ramify (version 0.3.3)

flatten: Flatten Matrices/Arrays

Description

Flatten (i.e., collapse) a matrix or array to one dimension.

Usage

flatten(x, across = c("rows", "columns"))

Arguments

x
A matrix object.
across
Character string specifying whether to flatten the matrix across "rows" (default) or "columns". This option is ignored for multi-way arrays.

Value

A numeric vector.

See Also

mat.

Examples

Run this code
m <- mat("2, 4, 6, 8; 10, 12, 14, 16")
flatten(m)
flatten(m, across = "columns")

Run the code above in your browser using DataLab