resize: Resize Matrices and Arrays

Description Usage Arguments Value See Also Examples

Description

Change shape and size of a matrix or array.

Usage

1
resize(x, nrow, ncol, ..., across = c("rows", "columns"), byrow = FALSE)

Arguments

x

A matrix or multi-way array.

nrow

The desired number of rows.

ncol

The desired number of columns.

...

Further dimensions of the array.

across

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

byrow

Logical. If FALSE (default) the new matrix is filled by columns, otherwise it is filled by rows. This option is ignored for multi-way arrays.

Value

A matrix with dimension nrow-by-ncol.

See Also

flatten, mat, matrix.

Examples

1
2
3
4
m <- 1:9
resize(m)
resize(m, 3, 3)
resize(m, 2, 2)

bgreenwell/ramify documentation built on May 12, 2019, 8:20 p.m.