Description Usage Arguments Details Value Examples
rray_diag()
creates a matrix filled with x
on the diagonal. Use offset
to place x
along an offset from the diagonal.
1 |
x |
A vector, matrix, array or rray. |
offset |
A single integer specifying the offset from the diagonal to
place |
No dimension names will be on the result.
A matrix, with x
on the diagonal.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Creates a diagonal matrix
rray_diag(1:5)
# Offset `1:5` by 1
rray_diag(1:5, 1)
# You can also go the other way
rray_diag(1:5, -1)
# Identity matrix
rray_diag(rep(1, 5))
# One interesting use case of this is to create
# a square empty matrix with dimensions (offset, offset)
rray_diag(rray(integer()), 3)
rray_diag(logical(), 3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.