This functions allows to set multiple elements of a matrix instead of using annoying step-by-step assignment by mat[1,2] <- 2 mat[2,3] <- 0.5 etc.
set_values(mat, ...) sv(mat, ...)
mat | a matrix object |
---|---|
... | formulae; left hand values should be two-element interger vectors and right-hand: a single-value numeric |
matrix
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 5 0 0 0.0 0 #> [2,] 0 0 0 0.0 0 #> [3,] 0 0 0 0.3 0 #> [4,] 0 0 0 0.0 0