Description Usage Arguments Details Value See Also Examples
Produces a ggplot biplot from an PCA analysis similar to biplot. Currently has methods for princomp and prcomp.
1 2 |
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 |
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
a ggplot object
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.