bandReplace: Replace matrix diagonals

View source: R/matrixOps.R

bandReplaceR Documentation

Replace matrix diagonals

Description

Sets a band of matrix diagonals to any given value

Usage

bandReplace(mat, lower, upper, value = NA, silent = TRUE)

Arguments

mat

A Matrix

lower

Lower diagonal to be included in the band (should be \le 0)

upper

Upper diagonal to be included in the band (should be \ge 0)

value

A single value to replace all values in the selected band (default = NA)

silent

Operate in silence, only (some) warnings will be shown (default = TRUE)

Value

A matrix in which the values in the selected diagonals have been replaced

Author(s)

Fred Hasselman

See Also

Other Distance matrix operations (recurrence plot): createCorridor(), mat_di2bi(), mat_di2ch(), mat_di2we(), mat_hamming(), rp(), rp_lineDist(), rp_nzdiags(), rp_plot(), rp_size()

Examples

# Create a 10 by 10 matrix
library(Matrix)
m <- Matrix(rnorm(10),10,10)

bandReplace(m,-1,1,0)   # Replace diagonal and adjacent bands with 0 (Theiler window of 1)

FredHasselman/casnet documentation built on April 20, 2024, 3:05 p.m.