my_size <- 3 M_identity <- matrix(0, nrow = my_size, ncol = my_size) # solution diag(M_identity) <- 1 print(M_identity)
Wihtin an R session, create an identity matrix (value 1 in the diagonal, zero in any other) of size 3X3. Tip: use the diag
function to define the diagonal of the matrix.
extype: string
exsolution: r mchoice2string(c(TRUE, FALSE, FALSE, FALSE, FALSE), single = TRUE)
exname: "matrix"
exshuffle: TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.