ggbiplot: Generic ggplot biplot function

Description Usage Arguments Details Value See Also Examples

Description

Produces a ggplot biplot from an PCA analysis similar to biplot. Currently has methods for princomp and prcomp.

Usage

1
2
ggbiplot(PC, selected.pc = c(1, 2), groups = NULL, scale = 1,
  length.alpha = T, ...)

Arguments

PC

a fitted object

selected.pc

vector of length 2 number of two principle components

groups

vector group assigned to each point

scale

scaling for explanatory variable arrows

length.alpha

logical wether transparency of explanatory variables should vary with length

...

other arguments to be passed to qplot

varnames

Details

If groups acts as stats:::biplot If groups is specified and has 6 or less unique values, observations are presented as different shapes for each group (ggplot shape argument) and circled with a 95 If groups is specified and has more than 6 unique values, observations are presented with different colours for each group (ggplot colour argument) and circled with a 95

Value

a ggplot object

See Also

biplot, prcomp, princomp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Can be used on the results of princomp and prcomp
p <- ggbiplot(PC=princomp(iris[,-5]))
print(p)
# For 6 or less groups, uses shape and linetype
p <- ggbiplot(PC=prcomp(iris[,-5]),
                   selected.pc=c(1,2),
                   groups=iris[,5],
                   main="PCA of iris dataset")
print(p)
# For more than 6 groups, uses colour
p <- ggbiplot(PC=prcomp(iris[,-5]),
                   selected.pc=c(1,2),
                   groups=sample(LETTERS[1:7],nrow(iris), replace=T),
                   main="PCA of iris dataset")
print(p)

low-decarie/ggpca documentation built on May 21, 2019, 7:50 a.m.