
Last chance! 50% off unlimited learning
Sale ends in
plot
method for class "dist"
. It displays a heatmap which is useful to preliminarily explore the presence of patterns (groups) of similar preferences in the ranking dataset.
# S3 method for dist
plot(
x,
order = TRUE,
show_labels = TRUE,
lab_size = 3,
gradient = list(low = "#00AFBB", mid = "white", high = "#FC4E07"),
...
)
A heatmap of the Spearman distance matrix between all pairs of full rankings.
An object of class "dist"
, returned by spear_dist
when setting the argument rho = NULL
.
Logical: whether the rows of the distance matrix must be ordered. Defaults to TRUE
.
Logical: whether the labels must be displayed on the axes. Defaults to TRUE
.
Positive scalar: the magnification of the labels on the axes. Defaults to 3.
List of three elements with the colors for low, mid and high values of the distances in the heatmap. The element mid
can take the value NULL
.
Further arguments passed to or from other methods (not used).
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
.
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
spear_dist
## 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)
Run the code above in your browser using DataLab