Adds convex hulls for a categorical variable to a MCA cloud of individuals.

ggadd_chulls(p, resmca, var, sel = 1:nlevels(var), axes = c(1,2), prop = 1, 
alpha = 0.2, label = TRUE, label.size = 5, legend = "right")

Arguments

p

ggplot2 object with the cloud of individuals

resmca

object of class MCA, speMCA, csMCA, stMCA or multiMCA

var

Factor. The categorical variable used to plot chulls.

sel

numeric vector of indexes of the categories to plot (by default, ellipses are plotted for every categories)

axes

numeric vector of length 2, specifying the components (axes) to plot. Default is c(1,2).

prop

proportion of all the points to be included in the hull (default is 1).

alpha

Numerical value from 0 to 1. Transparency of the polygon's fill. Default is O.2

label

Logical. Should the labels of the categories be plotted at the center of chulls ? Default is TRUE.

label.size

Size of the labels of the categories at the center of chulls. Default is 5.

legend

the position of legends ("none", "left", "right", "bottom", "top", or two-element numeric vector). Default is right.

Value

a ggplot2 object

Note

Chulls are colored according to the categories of the variable, using the default ggplot2 palette. The palette can be customized using any scale_color_* and scale_fill_* functions, such as scale_color_brewer() and scale_fill_brewer(), scale_color_grey() and scale_fill_grey(), or scale_color_manual() and scale_fill_manual().

References

Le Roux B. and Rouanet H., Multiple Correspondence Analysis, SAGE, Series: Quantitative Applications in the Social Sciences, Volume 163, CA:Thousand Oaks (2010).

Le Roux B. and Rouanet H., Geometric Data Analysis: From Correspondence Analysis to Stuctured Data Analysis, Kluwer Academic Publishers, Dordrecht (June 2004).

Author

Nicolas Robette

Examples

# specific MCA of Taste example data set
data(Taste)
junk <- c("FrenchPop.NA", "Rap.NA", "Rock.NA", "Jazz.NA", "Classical.NA",
          "Comedy.NA", "Crime.NA", "Animation.NA", "SciFi.NA", "Love.NA", 
          "Musical.NA")
mca <- speMCA(Taste[,1:11], excl = junk)
# hierarchical clustering 
# and partition of the individuals into 3 clusters
d <- dist(mca$ind$coord[, c(1,2)])
hca <- hclust(d, "ward.D2")
cluster <- factor(cutree(hca, 3))
# cloud of individuals
# with convex hulls for the clusters.
p <- ggcloud_indiv(mca, col = "black")
ggadd_chulls(p, mca, cluster)