Learn R Programming

diagonals (version 0.2.0)

minus_rectangle_matrix: Minus Rectangle Matrix

Description

Minus Rectangle Matrix

Usage

minus_rectangle_matrix(x, steps = NULL, size = NULL, replacement = 0)

Arguments

x
a matrix where the dimensions are both multiples of size
steps
the required number of steps (block matrices) across the diagonal
size
the largest dimension of the matrix being dropped over the diagonal of matrix x
replacement
value to be inserted on the diagonal, by default this is zero (0).

Examples

Run this code
# create a non-square matrix
nsm <- matrix(1:27, nrow=9, ncol=3 )

# check that both dimensions are multiples of steps=3
dim(nsm) %% 3 == c(0, 0)

# select the diagonal matrix
minus_rectangle_matrix(nsm, steps=3)

Run the code above in your browser using DataLab