Learn R Programming

extracat (version 1.6-3)

spread: Matrix Expansion

Description

Replaces each element of a matrix with a submatrix (containing this element) with a prespecified number of rows and columns.

Usage

spread(M, ncol = 1, nrow = 1)

Arguments

M
The matrix to be expanded.
ncol
The number of column repetitions.
nrow
The number of row repetitions.

Value

  • A matrix.

Examples

Run this code
M = matrix(1:12, ncol=4)
 spread(M, ncol = 5, nrow = 7)

Run the code above in your browser using DataLab