Learn R Programming

soc.ca (version 0.8.1)

add.categories: Add a layer of categories (modalities) to an mca map

Description

Add a layer of categories (modalities) to an mca map

Usage

add.categories(
  object,
  preset = c("active", "ctr", "sup", "all"),
  dim = c(1, 2),
  cats = extract_mod(object, dim),
  mapping = aes(label = Modality),
  repel = FALSE,
  check_overlap = FALSE,
  points = FALSE,
  draw.labels = TRUE,
  ...
)

Value

a ggplot2 object that can be added to an existing plot like those produced by map.ca.base

Arguments

object

a soc.mca result object

preset

a character string selecting among presets. If "active" - no change is made to "cats".

dim

a numeric vector with the dimensions for the plane

cats

a data.frame with coordinates of categories as produced by extract_mod or extract_sup. This controls the plotted points.

mapping

a call to aes from the ggplot2 package. Here you can map aesthetics to variables such as color, alpha, size and family.

repel

if TRUE label position is adjusted to lower overlap

check_overlap

if TRUE overlapping categories are removed

points

if TRUE points are plotted

draw.labels

if TRUE labels are plotted

...

further arguments are passed onto geom_text or geom_text_repel

Details

The `preset` argument adds, replaces or filters categories in `cats`:

  • `"ctr"`: returns all categories contributing above average to the plane defined in `dim`.

  • `"sup"`: returns the supplementary categories from `object`.

  • `"all"`: returns both supplementary and active categories.

Examples

Run this code
example(soc.mca)
map.ca.base() + add.categories(result, check_overlap = TRUE)
map.ca.base() + add.categories(result, preset = "all",
                mapping = aes(color = type, label = Modality), repel = TRUE)

Run the code above in your browser using DataLab