ggBiplot: PCA biplots with ggplot2

Description Usage Arguments Value Examples

Description

PCA biplots with ggplot2

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
ggBiplot(
  fit,
  choices = c(1, 2),
  groups = NULL,
  pc.biplot = T,
  coord_equal = F,
  ellipse = F,
  ellipse.prob = 0.9,
  kde = F,
  circle = F,
  circle.prob = 0.9,
  var.axes = T,
  var.names = T,
  varname.size = 4.125,
  varname.adjust = 1,
  varname.abbrev = T,
  labels = NULL,
  labels.size = 3,
  scale = 1,
  obs.scale = 1 - scale,
  var.scale = scale,
  alpha = 0.75,
  lwd = 1.25,
  klwd = 1.5,
  ...
)

Arguments

fit

object types supported from this package: "PrincipalComp", "sdr", "gpls", "gpcr", "ldarob", "facanal".

"Pca" (rrcov), "PcaRobust" (rrcov), "mvPCA" (MNM), "ics" (ICS), "factanal" (stats), "fa" (psych), "lda" (MASS)

choices

a vector of length 2 indicating which components to plot. defaults to the first two, ie c(1, 2).

groups

optional factor variable indicating the groups that the observations belong to. if provided the points will be colored according to groups

pc.biplot

for compatibility with biplot.princomp()

coord_equal

should the coordinate system be set to maintain a symmetric shaped plot? defaults to FALSE.

ellipse

draw a gaussian data ellipse for each group?

ellipse.prob

size of the ellipse in gaussian probability

kde

if TRUE, plots the kernel density estimate contours instead of points. useful for dense data. defaults to FALSE.

circle

draw a correlation circle? (only applies when prcomp was called with scale = TRUE and when var.scale = 1)

var.axes

draw arrows for the variables?

var.names

should labels be drawn for the variable axes?

varname.size

size of the text for variable names

varname.adjust

adjustment factor the placement of the variable names, >= 1 means farther from the arrow

varname.abbrev

whether or not to abbreviate the variable names

labels

optional vector of labels for the observations

labels.size

size of the text used for the labels

scale

covariance biplot (scale = 1), form biplot (scale = 0). when scale = 1, the inner product between the variables approximates the covariance and the distance between the points approximates the Mahalanobis distance.

obs.scale

scale factor to apply to observations

var.scale

scale factor to apply to variables

alpha

alpha transparency value for the points (0 = transparent, 1 = opaque)

lwd

the size of the variable axes. defaults to 1.25.

klwd

the thickness of the kde contours if kde=TRUE. defaults to 1.5.

Value

a ggplot2 plot

Examples

1
2
3
  data(wine)
  wine.pca <- PrincipalComp(wine, ncomp = 3)
  print(ggBiplot(wine.pca, groups = wine.class, ellipse = TRUE))

abnormally-distributed/cvreg documentation built on May 3, 2020, 3:45 p.m.