Skip to content

Instantly share code, notes, and snippets.

View acvill's full-sized avatar
🪗

Albert Vill acvill

🪗
View GitHub Profile
@acvill
acvill / tri2sym.R
Last active October 24, 2023 15:50
create a symmetric matrix by reflecting the top or bottom triangle
tri2sym <-
function(m, triangle) {
if (!is.numeric(m)) {
message("matrix must be numeric")
stop()
}
if (dim(m)[1] != dim(m)[2]) {
message("matrix must be square")
stop()
}