# NOT RUN {
# 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)
# }
Run the code above in your browser using DataLab