extract_tri | R Documentation |
extract upper or lower triangle from a square matrix
extract_tri(square.matrix, result.file, upper = FALSE, keep.diag = TRUE)
square.matrix |
a pairwise matrix object |
result.file |
a character string name of your result file |
upper |
a logical indicating that you want to keep the upper triangle (default=FALSE) |
keep.diag |
a logical indicating that you want to keep the diagonal in your trimat (default=TRUE) |
a trimatrix object and .csv file
Chris Brauer
## set directory for results to be written
setwd("path/to/working/directory")
# load example matrix
example.mat <- matrix(c(0,3,5,6, 3,0,6,6, 5,6,0,3, 6,6,3,0),
nrow = 4, ncol = 4, dimnames = list(c("A", "B", "C", "D"),
c("A", "B", "C", "D")))
# extract lower trimarix
Lmat <- extract_tri(example.mat, "lowermat")
# extract upper trimarix without the diagonal
Umat <- extract_tri(example.mat, "uppermat", upper = TRUE, keep.diag = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.