addArrowsAndNames: Add arrows and names to a factorial graph created by...

View source: R/getBiplot4PCA.R

addArrowsAndNamesR Documentation

Add arrows and names to a factorial graph created by createFactorMap and friends.

Description

addArrowsAndNames: Add arrows and names to a factorial graph created by createFactorMap and friends. Use, for example, to create a biplot by adding variables to the observation map

Usage

addArrowsAndNames(
  DATA,
  axis1 = 1,
  axis2 = 2,
  fontface = "bold.italic",
  color = "darkolivegreen"
)

Arguments

DATA

a matrix or data frame with coordinates of the items to be plotted (NB needs to have row names).

axis1

horizontal axis (Default: 1).

axis2

vertical axis (Default: 2).

fontface

font face for the names (Default: 'bold.italic').

color

an element or a vector of color (Default: 'darkolivegreen').

Details

To be used as an add-on for map created by createFactorMap. Note that for strange reasons (i.e., ggplot2 internals ....), the returned list cannot be provided with a class (and so the print function cannot give a help)

Value

A list with two elements

  1. arrows (ggplot code to add the arrows)

  2. labels4Biplot (ggplot code to add the names of the items): Uses ggplot2::annotate().

Author(s)

Hervé Abdi

See Also

getBiplotCoor

Examples

## Not run: 
data("twentyWines") # get the wine data set
resPCA <- ExPosition::epPCA(twentyWines$df.active, 
                            scale = FALSE, graphs = FALSE)
getCoordinates <- getBiplotCoor(resPCA) # get biplot coordinates
aMap <- PTCA4CATA::createFactorMap(resPCA$ExPosition.Data$fi, 
         constraints = getCoordinates$constraints4Biplot) # create base map
add2Map <- addArrowsAndNames(getCoordinates$coordArrow) # get the arrows
print(aMap$zeMap + add2Map) # print the biplot map

## End(Not run)

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