Learn R Programming

ChemoSpec (version 3.0-1)

plotScores: Plot PCA Scores of a Spectra Object

Description

Plots the requested PCA scores using the color scheme derived from a "Spectra" object. Options are provided to add confidence ellipses for each group in the object. The ellipses may be robust or classical. Option to label the extreme points provided.

Usage

plotScores(spectra, pca, pcs = c(1, 2),
	ellipse = "none", tol = "none",
	use.sym = FALSE, leg.loc = "topright", ...)

Arguments

spectra
An object of S3 class "Spectra".
pca
An object of class prcomp, modified to include a list element called $method, a character string describing the pre-processing carried out and the type of PCA performed (it appears on the plot).
pcs
A vector of two integers specifying the PCA scores to plot.
ellipse
A character vector specifying the type of ellipses to be plotted. One of c("both", "none", "cls", "rob"). cls specifies classical confidence ellipses, rob specifies robust confidence ellipses.
tol
A number describing the fraction of points to be labeled. tol = 1.0 labels all the points; tol = 0.05 labels the most extreme 5 percent.
use.sym
A logical; if true, the color scheme is set to black and the points plotted with symbols.
leg.loc
Character; if "none" no legend will be drawn. Otherwise, any string acceptable to legend.
...
Additional parameters to be passed to the plotting functions.

Value

  • None. Side effect is a plot.

References

https://github.com/bryanhanson/ChemoSpec

See Also

For other ways of displaying the results, plotScree, plotLoadings, plot2Loadings. For a 3D plot of the scores, see plotScores3D.

Examples

Run this code
data(SrE.IR)
results <- classPCA(SrE.IR, choice = "noscale")
myt <- expression(bolditalic(Serenoa)~bolditalic(repens)~bold(IR~Spectra))
plotScores(SrE.IR, main = myt, results,
	pcs = c(1,2), ellipse = "rob", tol = 0.05)

Run the code above in your browser using DataLab