Diag {lazy.mat} | R Documentation |
Diag(x) creats a diagonam matrix from its argument vector or matrix
Diag(x, drop = FALSE)
x |
Input square matrix or scalar |
drop |
= 1 to make the result a scalar when Diag(x) is 1 x 1. |
Diag(x) returns a diagonal matrix whose diagonal elements are:
1) the diagonal elements of x when x is a genuine matrix,
2) x when x is a vector, row vector, or column vector.
Can be used with a character matrix
A diagonal matrix
Diag(demomat(2,2)) Diag(1:3) Diag(matrix(1:3,1)) Diag(2)