expand: Expand a matrix

Description Usage Arguments Details Value Author(s) Examples

Description

expand expand a matrix to a new nrow and ncol matrix.

Usage

1
2
  expand(x, nrow = NULL, ncol = NULL, what = NULL,
    drop = TRUE)

Arguments

x

A matrix

nrow

Number of rows

ncol

Number of columns

what

If nrow > nrow(x) and/or ncol > ncol(x), values are replaced by what's in what

drop

If TRUE, delete the unnecessary dimension of a matrix (with drop)

Details

Values are replicated as necessary to fit the new dimensions of the matrix, or replaced by what.

Value

A vector or a matrix.

Author(s)

David Hajage dhajage@gmail.com

Examples

1
2
3
4
5
mat <- matrix(1:4, 2, 2)
expand(mat, 6, 7)
expand(mat, 6, 7, what = NA)
expand(mat, 1, 7)
expand(mat, 1, 7, drop = FALSE)

eusebe/markup documentation built on May 16, 2019, 9:35 a.m.