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 "dist", returned by spear_dist when setting the argument rho = NULL.

order

Logical: whether the rows of the distance matrix must be ordered. Defaults to TRUE.

show_labels

Logical: whether the labels must be displayed on the axes. Defaults to TRUE.

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 mid can take the value of NULL.

...

Further arguments passed to or from other methods (not used).

Details

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

spear_dist

Examples


## Example 1. Plot the Spearman distance matrix of the Antifragility ranking dataset.
dist_mat <- spear_dist(rankings = ranks_antifragility)
plot(dist_mat, show_labels = FALSE)

## Example 2. Plot the Spearman distance matrix of the Sports ranking dataset.
n <- 8
dist_mat <- spear_dist(rankings = ranks_sports[, 1:n])
plot(dist_mat, show_labels = FALSE)
# Plot the Spearman distance matrix for the subsample of males.
dist_m <- spear_dist(rankings = ranks_sports[, 1:n], subset = ranks_sports$Gender == "Male")
plot(dist_m)



[Package MSmix version 1.0.1 Index]