plot.dist {MSmix} | R Documentation |
Plot the Spearman distance matrix
Description
plot
method for class "dist"
. It is useful to preliminary explore the presence of patterns (groups) of similar preferences in the ranking dataset.
Usage
## S3 method for class 'dist'
plot(
x,
order = TRUE,
show_labels = TRUE,
lab_size = 3,
gradient = list(low = "#00AFBB", mid = "white", high = "#FC4E07"),
...
)
Arguments
x |
An object of class |
order |
Logical: whether the rows of the distance matrix must be ordered. Defaults to |
show_labels |
Logical: whether the labels must be displayed on the axes. Defaults to |
lab_size |
Positive scalar: the magnification of the labels on the axes. Defaults to 3. |
gradient |
List of three elements with the colors for low, mid and high values of the distances in the heatmap. The element |
... |
Further arguments passed to or from other methods (not used). |
Details
plot.dist
can visualize a distance matrix of any metric, provided that its class is "dist"
. It can take a few seconds if the size of the distance matrix is large.
The heatmap can be also obtained by setting the arguments rho = NULL
and plot_dist_mat = TRUE
when applying spear_dist
.
Value
Produce a heatmap of the Spearman distance matrix between all pairs of full rankings.
References
Alboukadel K and Mundt F (2020). factoextra: Extract and Visualize the Results of Multivariate Data Analyses. R package version 1.0.7. https://CRAN.R-project.org/package=factoextra
See Also
Examples
## Example 1. Plot the Spearman distance matrix of the Antifragility ranking dataset.
r_antifrag <- ranks_antifragility[, 1:7]
dist_mat <- spear_dist(rankings = r_antifrag)
plot(dist_mat, show_labels = FALSE)
## Example 2. Plot the Spearman distance matrix of the Sports ranking dataset.
r_sports <- ranks_sports[, 1:8]
dist_mat <- spear_dist(rankings = r_sports)
plot(dist_mat, show_labels = FALSE)
# Plot the Spearman distance matrix for the subsample of males.
dist_m <- spear_dist(rankings = r_sports, subset = (ranks_sports$Gender == "Male"))
plot(dist_m)