Package 'ggbiplot'

Title: A ggplot2 based biplot
Description: A ggplot2 based biplot. It provides a drop-in replacement for biplot.princomp(). It implements a biplot and scree plot using ggplot2.
Authors: Vincent Q. Vu <[email protected]>
Maintainer: Vincent Q. Vu <[email protected]>
License: GPL-2
Version: 0.55
Built: 2025-03-14 04:44:09 UTC
Source: https://github.com/vqv/ggbiplot

Help Index


Biplot for Principal Components using ggplot2

Description

Biplot for Principal Components using ggplot2

Usage

ggbiplot(pcobj, choices = 1:2, scale = 1, pc.biplot =
  TRUE, obs.scale = 1 - scale, var.scale = scale, groups =
  NULL, ellipse = FALSE, ellipse.prob = 0.68, labels =
  NULL, labels.size = 3, alpha = 1, var.axes = TRUE, circle
  = FALSE, circle.prob = 0.69, varname.size = 3,
  varname.adjust = 1.5, varname.abbrev = FALSE, ...)

Arguments

pcobj

an object returned by prcomp() or princomp()

choices

which PCs to plot

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

pc.biplot

for compatibility with biplot.princomp()

groups

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

ellipse

draw a normal data ellipse for each group?

ellipse.prob

size of the ellipse in Normal probability

labels

optional vector of labels for the observations

labels.size

size of the text used for the labels

alpha

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

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?

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

Value

a ggplot2 plot

Examples

data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE))

Screeplot for Principal Components

Description

Screeplot for Principal Components

Usage

ggscreeplot(pcobj, type = c("pev", "cev"))

Arguments

pcobj

an object returned by prcomp() or princomp()

type

the type of scree plot. 'pev' corresponds proportion of explained variance, i.e. the eigenvalues divided by the trace. 'cev' corresponds to the cumulative proportion of explained variance, i.e. the partial sum of the first k eigenvalues divided by the trace.

Examples

data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
print(ggscreeplot(wine.pca))

Chemical composition of three cultivars of wine

Description

Chemical constituents of wines from three different cultivars grown in the same region in Italy. The cultivars, 'barolo', 'barbera', and 'grignolino', are indicated in wine.class.

Usage

data(wine)

Format

The format is: chr "wine"

Source

http://archive.ics.uci.edu/ml/datasets/Wine

Examples

data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
print(ggscreeplot(wine.pca))                                               
print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE))