View source: R/distance_to_rectangular.R
distance_to_rectangular | R Documentation |
distance_to_rectangular
converts binary triangular matrices to rectangular matrices using Multidimensional Scaling.
distance_to_rectangular(
distance.matrix,
labels = names(distance.matrix),
n.dimensions = 2,
metric = TRUE,
...
)
distance.matrix |
Distance matrix (i.e. object of class 'dist'). Can be created using the function |
labels |
Character vector or factor containing labels to be used for rows/columns in the output data frame. Default is |
n.dimensions |
Integer vector of length 1 indicating the number of of dimensions to represent distances in a new space. Default is 2. |
metric |
Logical argument to control if Metric (a.k.a. Classical, |
... |
Additional arguments to be passed to |
It is a silly wrapper over 2 multidimensional scaling functions (isoMDS
and cmdscale
) that simplifies the calculation of Multidimensional Scaling and formatting of its output to be used with other functions in the package.
A data frame with the new dimensions representing the position of observations in a new n-dimension space. If metric = FALSE
the output data frame is embedded in a list that also includes the stress value.
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
, rectangular_to_triangular
{
data("example_space")
dist_example <- dist(example_space[example_space$group %in% c("G1", "G2"),
c("dimension_1", "dimension_2")])
# convert into a 2-dimension space
rect_example <- distance_to_rectangular(distance.matrix = dist_example,
metric = TRUE)
head(rect_example)
# convert into a 2-dimension space with non-metric MDS
rect_example <- distance_to_rectangular(distance.matrix = dist_example,
metric = FALSE, maxit = 3)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.