Search notes:

R function: diag

diag(7)
#      [,1] [,2] [,3] [,4] [,5] [,6] [,7]
# [1,]    1    0    0    0    0    0    0
# [2,]    0    1    0    0    0    0    0
# [3,]    0    0    1    0    0    0    0
# [4,]    0    0    0    1    0    0    0
# [5,]    0    0    0    0    1    0    0
# [6,]    0    0    0    0    0    1    0
# [7,]    0    0    0    0    0    0    1
Github repository about-r, path: /functions/diag.R

See also

Matrix operations
Index to (some) R functions

Index