GDAtools (version 1.5)

ggadd_interaction: Adds the interaction between two categorical supplementary variables to a MCA cloud of variables

Description

Adds the interaction between two categorical supplementary variables to a MCA cloud of variables, using the ggplot2 framework.

Usage

ggadd_interaction(p, resmca, v1, v2, sel1=1:nlevels(v1), sel2=1:nlevels(v2),
axes=c(1,2), col=NULL, textsize=5, legend='right')

Arguments

p

ggplot object with the cloud of variables

resmca

object of class 'MCA', 'speMCA' or 'csMCA'.

v1

Factor. The first categorical supplementary variable.

v2

Factor. The second categorical supplementary variable.

sel1

Numeric vector of indexes of the categories of the first supplementary variable to be used in interaction. By default, every categories are used.

sel2

Numeric vector of indexes of the categories of the second supplementary variable to be used in interaction. By default, every categories are used.

axes

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

col

Colors for the ellipses and labels of the categories. Can be the name of a palette from the RcolorBrewer package, 'bw' for a black and white palette (uses scale_color_grey()), a character vector of colors for a custom palette, or the name of a color for a single color. If NULL (default), the default palette of ggplot2 is used.

textsize

Size of the labels of categories. Default is 5.

legend

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

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

Examples

Run this code
# NOT RUN {
## Performs a specific MCA on 'Music' example data set
## ignoring every 'NA' (i.e. 'not available') categories,
## draws the cloud of categories
## and adds the interaction between Gender and Age.
data(Music)
getindexcat(Music[,1:5])
mca <- speMCA(Music[,1:5],excl=c(3,6,9,12,15))
p <- ggcloud_variables(mca, palette='lightgrey', shapes=FALSE)
ggadd_interaction(p, mca, Music$Gender, Music$Age)
# }

Run the code above in your browser using DataLab