set_diag {holodeck} | R Documentation |
Pipe friendly wrapper to 'diag(x) <- value'
set_diag(x, value)
x |
a matrix |
value |
either a single value or a vector of length equal to the diagonal of 'x'. |
a matrix
library(dplyr)
matrix(0,3,3) %>%
set_diag(1)