map4DotsAndLabels: Create 'ggplot2' factorial maps for dots and labels. NB needs...

View source: R/CreateFactorMaps4CA.R

map4DotsAndLabelsR Documentation

Create ggplot2 factorial maps for dots and labels. NB needs a base map to work correctly

Description

map4DotsAndLabels: Creates ggplot2 factorial map for dots and labels. NB: needs a base map to work correctly. create the base plot maps for CA type graphs with ggplot2

Usage

map4DotsAndLabels(
  data,
  axis1 = 1,
  axis2 = 2,
  display.points = TRUE,
  col.points = "blueviolet",
  alpha.points = 0.5,
  pch = 19,
  cex = 2.5,
  display.labels = TRUE,
  col.labels = "darkorchid4",
  alpha.labels = 1,
  force = 1,
  segment.size = 0,
  text.cex = 4,
  font.face = "bold",
  font.family = "sans",
  nudge_x = 0,
  nudge_y = 0,
  ...
)

Arguments

data

the factor scores to plot

axis1

the column of X used for the horizontal axis of the plot. Default 1.

axis2

the column of X used for the vertical axis of the plot. Default 2.

display.points

if TRUE (Default) create the map for the points.

col.points

the color of the points/dots. Can be one color or a vector of colors. If a vector it needs to have exactly the number of items to be plotted. Default = 'blueviolet'.

alpha.points

(default = .5), the alpha (transparency) for the points, should be between 1 (no transparency) and 0 (completely transparent).

pch

the character for the points, Default is 19 (Circles).

cex

size of the dots. Default = 2.5

display.labels

if TRUE (default), create the map for the labels.

col.labels

the color of the labels Can be one color or a vector of colors. If a vector it needs to have exactly the number of items to be plotted. Default = 'darkorchid'.

alpha.labels

(default = 1), the alpha (transparency) for the labels, should be between 1 (no transparency) and 0 (completely transparent).

force

= 1. How much ggrepel repels the labels.

segment.size

= 0, size of segment line for ggrpel.

text.cex

= 4, font size for labels.

font.face

(default = 'bold') font for labels.

font.family

(default = 'sans'), font family for labels.

nudge_x

(default = 0). From ggrepel, nudge value for starting point for labels: x dimension.

nudge_y

(default = 0). From ggrepel, nudge value for starting point for labels: y dimension. @param alpha.point (default = .5), the alpha (transparency) for the points, should be between 1 (no transparency) and 0 (completely transparent).

...

everything else to pass to the functions

Value

a list with 6-elements:

  1. zeMap: The Complete Map (background Dots and Labels);

  2. zeMap_background: The Background map;

  3. zeMap_dots: The dots;

  4. zeMap_text: The Labels;

  5. factorScores: The factor scores; and

  6. constraints: The list of the contraints (could be used to generate other graphs with the same scaling factors).

Important_Note

When creating multiple layers graphs, because of the way ggplot2 create graphs, all the matrices/dataframe should all the have the same column names [e.g., colnames() equal to c("Dimension 1", "Dimension 2")]. When it is not the case, some strange and cryptic error may be produced (e.g., "cannot find Dimension").

Author(s)

Herve Abdi

See Also

createFactorMap createBaseMap


HerveAbdi/PTCA4CATA documentation built on July 17, 2022, 5:41 a.m.