powered by
mdiag(x, k = 0)
x
mdiag(x, k)
If x is a matrix, mdiag(x, k) returns the (k-th secondary) diagonal of x.
k
The k-th secondary diagonal is above the main diagonal for k > 0 and below the main diagonal for k < 0.
k > 0
k < 0
diag
mtrace
mdiag(matrix(1:12,3,4), 1) mdiag(matrix(1:12,3,4), -1) mdiag(c(1,5,9), 1) mdiag(c(1,5,9), -1)
Run the code above in your browser using DataLab