addArrows: Add arrows to a factorial map (best with a circle of...

View source: R/addCircleOfCor.R

addArrowsR Documentation

Add arrows to a factorial map (best with a circle of Correlation).

Description

addArrows: Add arrows to a factorial map (i.e., a PCA-like map), most likely a plot of correlation produced by createFactorMap et alia.

Usage

addArrows(
  X,
  axis1 = 1,
  axis2 = 2,
  color = "darkorchid",
  alpha = 0.6,
  size = 1,
  center = c(0, 0),
  arrowLength = 0.3,
  linetype = 1
)

Arguments

X

a data frame with the coordinates of the points (e.g., from ExPosition::epCA()).

axis1

(default = 1) The number of the column of X for the horizontal axis.

axis2

(default = 2) The number of the column of X for the vertical axis.

color

the color of the arrows. Can be one color or a vector of colors. If color is a vector, it needs to have exactly as many elements as the number of arrows to plot. Default = 'darkorchid'.

alpha

(Default: 0.6), the alpha (transparency) for the arrows, should be between 1 (no transparency) and 0 (completely transparent).

size

(Default = 1), the thickness of the segment

center

(Default: c(0, 0)) the center of the graph

arrowLength

(Default: 0.3), the length (in cm.) of the terminal arrow.

linetype

(Default = 1 = solid), the type of the line; should match ggplots2 linetype or basic R, lty (e.g., 2 = dashed, 3 = dotted).

Details

The map should should first be created by, for example, createFactorMap() (or equivalent functions from PTCA4CATA), and then the arrows are added (see example). addArrows is typically used with addCircleOfCor.

Value

a ggplot2 component to be added to a scatterplot / map (typically created by createFactorMap()).

See Also

annotate addCircleOfCor createFactorMap

Examples

## Not run: 
# Some PCA-like correlations
corXY <- matrix(c(.5,-.5, .1,.7, .8,.5, -.1,.9,  -.6,-.6),
               ncol = 2, byrow = TRUE )
# create a map of correlation
MapCor <- createFactorMap(corXY,
         constraints = list(minx = -1, miny = -1,
                            maxx = 1 , maxy = 1) )
# Add arrows and a circle to the base Map
ggMapWithCircle <- MapCor$zeMap +  addArrows(corXY) + addCircleOfCor()
# To print the map with arrows and circle:
# print(ggMapWithCircle)

## End(Not run)

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