tr <- function(x) { stopifnot(is.matrix(x), dim(x)[[1L]] == dim(x)[[2L]]) # Ensure x is square matrix sum(diag(x)) }
Add the following code to your website.
REMOVE THIS Copy to clipboard
For more information on customizing the embed code, read Embedding Snippets.