Learn R Programming

GDAtools (version 2.1)

ggadd_chulls: Convex hulls for a categorical supplementary variable

Description

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

Usage

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")

Value

a ggplot2 object

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.

Author

Nicolas Robette

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).

See Also

ggcloud_indiv, ggadd_supvar, ggadd_supvars, ggadd_kellipses, ggadd_ellipses, ggadd_interaction, ggsmoothed_supvar, ggadd_corr, ggadd_density

Examples

Run this code
# 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)

Run the code above in your browser using DataLab