
Last chance! 50% off unlimited learning
Sale ends in
Plotting functions for PCA: for scores, loadings, scores and loadings simultaneously (a biplot), and variances (a screeplot, where the log of the explained variance is plotted for each PC).
# S3 method for PCA
scoreplot(object, pc = c(1, 2), pcscores = scores(object),
show.names = FALSE, xlab, ylab, xlim, ylim, …)
# S3 method for PCA
loadingplot(object, pc = c(1, 2), pcloadings = loadings(object),
scalefactor = 1, add = FALSE, show.names = FALSE,
xlab, ylab, xlim, ylim, col = "blue", min.length =
0.01, varnames = NULL, …)
# S3 method for PCA
biplot(x, pc = c(1,2),
show.names = c("none", "scores", "loadings", "both"),
score.col = 1, loading.col = "blue",
min.length = .01, varnames = NULL, …)
screeplot(object, type = c("scree", "percentage"), npc, …)
an object of class "PCA" (see below).
which PCs to show.
matrix of scores, by default the scores of the PCA model object.
show names rather than plotting
symbols. For loadingplot
and scoreplot
a logical
(default: FALSE), for biplot
one of 'scores', 'loadings',
'both' or 'none' (default).
graphical parameters of the plot.
matrix of loadings, by default the loadings of the PCA model object.
scaling factor for the loadings; used internally, when
the loadingplot
function is called from within
biplot.PCA
.
logical, whether to add to the existing plot (again, useful
when loadingplot
is called from within biplot.PCA
).
how many PCs to show in the scree plot (starting from 1).
show a real screeplot (scree
) or show the
percentage of variance explained (percentage
).
colours of the scores and loadings in a biplot.
minimal length of loading vectors to be plotted by arrows. Vectors that are too short lead to warning messages, are not interesting, and only clutter the graphic.
alternative vector of variable names.
Graphical arguments passed on to lower-level plotting functions.
Score plots and loading plots show the amount of explained variance at the axis labels only when PCA has been performed at mean-centered data.
R. Wehrens. "Chemometrics with R - Multivariate Data Analysis in the Natural Sciences and Life Sciences". Springer, Heidelberg, 2011.
# NOT RUN {
data(wines, package = "ChemometricsWithRData")
wines.PC <- PCA(scale(wines))
scoreplot(wines.PC, col = wine.classes, pch = wine.classes)
loadingplot(wines.PC, show.names = TRUE)
biplot(wines.PC, score.col = wine.classes)
screeplot(wines.PC)
# }
Run the code above in your browser using DataLab