addLines4MCA: ('ggplot2') add lines to the levels of the qualitative...

View source: R/goodies4MCA.R

addLines4MCAR Documentation

(ggplot2) add lines to the levels of the qualitative variables in a (variable) factorial map of an MCA (e.g., computed with ExPosition::epMCA).

Description

addLines4MCA is a ggplot2 based function that adds lines to join the levels of the qualitative variables in a factorial map of an MCA (e.g., computed with ExPosition::epMCA and created with createFactortMap).

Usage

addLines4MCA(
  Fj,
  col4Var,
  alpha = 0.7,
  linetype = 3,
  size = 0.5,
  axis_h = 1,
  axis_v = 2,
  dimension.names = "Dimension",
  ...
)

Arguments

Fj

the output for the column set of an MCA (e.g., from ExPosition::epMCA, this would be $ExPosition.Data$fj).

col4Var

vector of colors for the variables. if col4Var is not equal to the number of qualitative variables ExPosition::epMCA) will create these colors from prettyGraphsColorSelection.

alpha

(Default: 0.7) the alpha values for the lines.

linetype

(Default: 3, dotted) the linetype number for the lines.

size

(Default: .5) the size of the lines.

axis_h

(Default: 1) what is the horizontal axis.

axis_v

(Default: 2) hat is the verical axis.

dimension.names

(Default: 'Dimension')

...

Everything else that can be passed to ggplot2::geom_path().

Details

The levels of a given variable are first ordered by alphabetical order prior to drawing the lines (so, e.g., truc.1, truc.2 and truc.3 will be correctly ordered).

The name (i.e., stem) of a variable is obtained by stripping the names of the levels (i.e., columns) of the extension after the last "." of their names. For example, the name toto.1 for a row of Fj corresponds to the qualitative variable toto.

Value

A list with the lines for each variables

Important_Note

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

See Also

prettyGraphsColorSelection getVarNames

Examples

## Not run: 
if(interactive()){
library{ExPosition}
data("mca.wine")
resMCA    <- epMCA(mca.wine$data, graphs = FALSE)
Fj <- resMCA$ExPosition.Data$fj
baseMap4J <- createFactorMap(Fj)$zeMap +
  addLines4MCA(Fj,col4Var = rep('red',10) )
 }

## End(Not run)

HerveAbdi/data4PCCAR documentation built on Sept. 11, 2022, 4:19 p.m.