non.diagonal-set: Reassign values in the non diagonal part of a matrix similar...

Description Usage Arguments Value Examples

Description

Reassign values in the non diagonal part of a matrix similar use as its diag(x) and diag(x) <- value equivalent

Usage

1
non.diagonal(x) <- value

Arguments

x

matrix or other R object with length(dim(x)) == 2

value

scalar or vector of values to replace the non diagonal part of x with. Filled in by increasing row then by increasing column,

Value

a matrix with similar dimensions as x where the non-diagonal parts have been replaced by the value in value

Examples

1
2
3
4
5
6
7
8
9
set.seed(42)
M <- matrix(sample(1:10,16,replace = TRUE),4,4)
M
non.diagonal(M) <- round(runif(12,0,1))
M
non.diagonal(M) <- 42
M
non.diagonal(M) <- 1:12
M

R-KenK/SimuNet documentation built on Oct. 22, 2021, 1:27 a.m.