View source: R/rectangular_to_triangular.R
rectangular_to_triangular | R Documentation |
rectangular_to_triangular
converts rectangular pairwise matrices as those output by many PhenotypeSpace functions into triangular pairwise matrices.
rectangular_to_triangular(X, distance = TRUE, symmetric = TRUE)
X |
Data frame containing three columns. The first two columns must contain group labels which will appear as rows (1 column) and column names (2 column) in the output triangular matrix. The third column (and fourth column if |
distance |
Logical argument to control if the input data contains pairwise distances (dissimilarities) or similarities. If |
symmetric |
Logical argument to define if values are duplicated on both off-diagonal triangles (a symmetric triangular matrix, |
The function converts rectangular pairwise matrices as those output by many PhenotypeSpace functions into triangular pairwise matrices. It takes a data frame in which each observation (row) contains the pairwise value and related labels of the 'groups' being compared. The first two columns must contain group labels which will appear as rows (1 column) and column names (2 column) in the output triangular matrix. The third column (and fourth column if symmetric = FALSE
) must have the numeric values to be included in the output triangular matrix.
A pairwise triangular matrix in which labels from the first group column in 'X' are shown in the columns and labels from the second group are shown in the rows. If symmetric = FALSE
the same information is shown below and above the diagonal.
Marcelo Araya-Salas marcelo.araya@ucr.ac.cr)
Araya-Salas, M, & K. Odom. 2022, PhenotypeSpace: an R package to quantify and compare phenotypic trait spaces R package version 0.1.0.
distance_to_rectangular
, binary_triangular_matrix
{
# load data
data("example_space")
# get proportion of space that overlaps
prop_overlaps <- space_similarity(
formula = group ~ dimension_1 + dimension_2,
data = example_space,
method = "proportional.overlap")
# get symmetric triangular matrix
rectangular_to_triangular(prop_overlaps)
# get minimum convex polygon overlap for each group (non-symmetric)
mcp_overlaps <- space_similarity(
formula = group ~ dimension_1 + dimension_2,
data = example_space,
method = "mcp.overlap")
# get a non-symmetric triangular matrix
rectangular_to_triangular(mcp_overlaps, symmetric = FALSE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.