sym_mtx <- function(lower_tri, diag = TRUE, dimnames = NULL) {
n <- 0.5 * (sqrt(1 + 8 * length(lower_tri)) - 1)
if (diag) {
mtx <- matrix(nrow = n, ncol = n, dimnames = dimnames)
mtx[lower.tri(mtx, diag = TRUE)] <- lower_tri
} else {
n <- n + 1
mtx <- matrix(1, nrow = n, ncol = n, dimnames = dimnames)
mtx[lower.tri(mtx, diag = FALSE)] <- lower_tri
}
mtx[upper.tri(mtx, diag = FALSE)] <- mtx[lower.tri(mtx, diag = FALSE)]
mtx
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.