extract_tri: extract upper or lower triangle from a square matrix

Description Usage Arguments Value Author(s) Examples

Description

extract upper or lower triangle from a square matrix

Usage

1
2
extract_tri(square.matrix, result.file, upper = FALSE,
  keep.diag = TRUE)

Arguments

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)

Value

a trimatrix object and .csv file

Author(s)

Chris Brauer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 ## 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)

pygmyperch/melfuR documentation built on Oct. 10, 2020, 1:23 p.m.