flatten: Flatten Matrices/Arrays

Description Usage Arguments Value See Also Examples

Description

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

Usage

1
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

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

Example output

Attaching package: 'ramify'

The following object is masked from 'package:graphics':

    clip

[1]  2  4  6  8 10 12 14 16
[1]  2 10  4 12  6 14  8 16

ramify documentation built on May 2, 2019, 5:58 a.m.