diag(x)
and diag(x) <- value
equivalentR/matrix_tools.R
non.diagonal-set.Rd
Reassign values in the non diagonal part of a matrix
similar use as its diag(x)
and diag(x) <- value
equivalent
non.diagonal(x) <- value
x | matrix or other R object with |
---|---|
value | scalar or vector of values to replace the non diagonal part of |
a matrix with similar dimensions as x
where the non-diagonal parts have been replaced by the value in value
#> [,1] [,2] [,3] [,4] #> [1,] 1 10 1 9 #> [2,] 5 4 8 5 #> [3,] 1 2 7 4 #> [4,] 9 10 4 10#> [,1] [,2] [,3] [,4] #> [1,] 1 1 1 0 #> [2,] 1 4 0 1 #> [3,] 1 1 7 1 #> [4,] 0 0 1 10#> [,1] [,2] [,3] [,4] #> [1,] 1 42 42 42 #> [2,] 42 4 42 42 #> [3,] 42 42 7 42 #> [4,] 42 42 42 10#> [,1] [,2] [,3] [,4] #> [1,] 1 4 7 10 #> [2,] 1 4 8 11 #> [3,] 2 5 7 12 #> [4,] 3 6 9 10