Learn R Programming

GDAtools (version 1.7)

ggadd_density: Adds a density layer to the cloud of individuals for a category of a supplementary variable

Description

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.

Usage

ggadd_density(p, resmca, var, cat=levels(var)[1], axes=c(1,2),
density="contour", col.contour="darkred", pal.area="viridis", alpha.area=0.2,
ellipse=FALSE, col.ellipse="black")

Arguments

p

ggplot object with the cloud of variables

resmca

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

var

factor or numerical vector. The supplementary variable used for the heatmap.

cat

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

density

If "contour", density is plotted with contours. If "area", density is plotted with areas.

col.contour

character string. The color of the contours.

pal.area

character string. The name of a viridis palette for areas.

alpha.area

numeric. Transparency of the areas. Default is 0.2.

ellipse

logical. If TRUE, a concentration ellipse is added.

col.ellipse

character string. The color of the ellipse. Default is black.

Value

a ggplot object

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_variables, ggcloud_indiv, ggadd_supvar, ggadd_interaction, ggadd_ellipses, ggadd_corr

Examples

Run this code
# NOT RUN {
## Performs a specific MCA on 'Taste' example data set
## ignoring every 'NA' (i.e. 'not available') categories,
## draws the cloud of categories
## and adds a density layer for Age=50+.
data(Taste)
getindexcat(Taste[,1:11])
mca <- speMCA(Taste[,1:11],excl=c(3,6,9,12,15,18,21,24,27,30,33))
p <- ggcloud_indiv(mca, col='lightgrey')

# density layer with contours
ggadd_density(p, mca, var=Taste$Age, cat="50+")

# density layer with areas
ggadd_density(p, mca, var=Taste$Age, cat="50+", density="area")
# }

Run the code above in your browser using DataLab