ggadd_density.Rd
For a given category of a supplementary variable, adds a layer representing the density of points to the cloud of individuals, either with contours or areas.
ggplot2
object with the cloud of variables
object of class MCA
, speMCA
, csMCA
, stMCA
or multiMCA
factor or numerical vector. The supplementary variable to be plotted.
character string. The category of var
to plot (by default, the first level of var
is plotted). Only used if var is a factor.
numeric vector of length 2, specifying the components (axes) to plot. Default is c(1,2).
If "contour" (default), density is plotted with contours. If "area", density is plotted with areas.
character string. The color of the contours.
character string. The name of a viridis palette for areas.
numeric. Transparency of the areas. Default is 0.2.
logical. If TRUE, a concentration ellipse is added.
a ggplot2
object
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).
# 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)
p <- ggcloud_indiv(mca, col='lightgrey')
# density plot for Age = 50+ (with contours)
ggadd_density(p, mca, var = Taste$Age, cat = "50+")
# density plot for Age = 50+ (with contours)
ggadd_density(p, mca, var = Taste$Age, cat = "50+", density = "area")