ggadd_supvars {GDAtools} | R Documentation |
Plot of categorical supplementary variables
Description
Adds categorical supplementary variables to a MCA cloud of variables.
Usage
ggadd_supvars(p, resmca, vars, excl = NULL, points = "all", min.cos2 = 0.1,
axes = c(1,2), col = NULL,
shapes = FALSE, prop = NULL, textsize = 3, shapesize = 6,
vlab = TRUE, vname = NULL,
force = 1, max.overlaps = Inf)
Arguments
p |
|
resmca |
object of class |
vars |
A data frame of categorical supplementary variables. All these variables should be factors. |
excl |
character vector of supplementary categories to exclude from the plot, specified in the form "namevariable.namecategory" (for instance "Gender.Men"). If NULL (default), all the supplementary categories are plotted. |
points |
character string. If 'all' all categories are plotted (default); if 'besth' only those with a minimum squared cosine on horizontal axis are plotted; if 'bestv' only those with a minimum squared cosine on vertical axis are plotted; if 'besthv' only those with a minimum squared cosine on horizontal or vertical axis are plotted; if 'best' only those with a minimum squared cosine on the plane are plotted. |
min.cos2 |
numerical value. The minimal squared cosine if 'points' argument is different from 'all'. Default |
axes |
numeric vector of length 2, specifying the components (axes) to plot. Default is c(1,2). |
col |
character string. Color name for the labels (and the shapes if |
shapes |
Logical. If TRUE, symbols are used in addition to the labels of categories. Default is FALSE. |
prop |
If NULL, the size of the labels (if |
textsize |
Size of the labels of categories if |
shapesize |
Size of the shapes if |
vlab |
Logical. If TRUE (default), the variable name is added as a prefix for the labels of the categories. |
vname |
deprecated, use vlab instead |
force |
Force of repulsion between overlapping text labels. Defaults to 1. If 0, labels are not repelled at all. |
max.overlaps |
Exclude text labels that overlap too many things. Defaults to Inf, which means no labels are excluded. |
Value
a ggplot2
object
Note
Shapes and labels are colored according to the categories of the variable, using the default ggplot2
palette. The palette can be customized using any scale_color_*
function, such as scale_color_brewer()
, scale_color_grey()
or scale_color_manual()
.
Author(s)
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_variables
, ggadd_supvar
, ggadd_ellipses
, ggadd_kellipses
, ggadd_density
, ggadd_interaction
, ggsmoothed_supvar
, ggadd_chulls
, ggadd_corr
Examples
# specific MCA of Music example data set
data(Music)
junk <- c("FrenchPop.NA", "Rap.NA", "Rock.NA", "Jazz.NA", "Classical.NA")
mca <- speMCA(Music[,1:5], excl = junk)
# adds several supplementary variables
# onto the cloud of variables
p <- ggcloud_variables(mca, col = "lightgrey", shapes = FALSE)
ggadd_supvars(p, mca, Music[, c("Gender","Age")])
# the same, excluding men
ggadd_supvars(p, mca, Music[, c("Gender","Age")], excl = "Gender.Men")
# the same, keeping only categories
# with cos2 >= 0.001 for dimension 1
ggadd_supvars(p, mca, Music[, c("Gender","Age")], points = "besth", min.cos2 = 0.001)