Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plot2Loadings

Plot PCA Loadings from a Spectra Object Against Each Other


Description

Plots two PCA loadings specified by the user, and labels selected (extreme) points. Typically used to determine which variables (frequencies) are co-varying, although in spectroscopy most peaks are represented by several variables and hence there is a lot of co-varying going on. Also useful to determine which variables are contributing the most to the clustering on a score plot.

Usage

plot2Loadings(spectra, pca, loads = c(1, 2), tol = 0.05, ...)

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). This is automatically provided if ChemoSpec functions c_pcaSpectra or r_pcaSpectra were used to create pca.

loads

A vector of two integers specifying which loading vectors to plot.

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.

...

Other parameters to be passed to the plotting routines.

Value

None. Side effect is a plot.

Author(s)

Bryan A. Hanson, DePauw University.

See Also

See plotLoadings to plot one loading against the original variable (frequency) axis. See sPlotSpectra for a different approach. Additional documentation at https://bryanhanson.github.io/ChemoSpec/

Examples

data(SrE.IR)
pca <- c_pcaSpectra(SrE.IR)
myt <- expression(bolditalic(Serenoa) ~ bolditalic(repens) ~ bold(IR ~ Spectra))
res <- plot2Loadings(SrE.IR, pca,
  main = myt,
  loads = c(1, 2), tol = 0.001
)

ChemoSpec

Exploratory Chemometrics for Spectroscopy

v5.3.11
GPL-3
Authors
Bryan A. Hanson [aut, cre] (<https://orcid.org/0000-0003-3536-8246>), Mike Bostock [cph, ctb] (author of the d3.js library used by plotSpectraJS, http://d3js.org), Matt Keinsley [ctb] (author of initial AOV-PCA code)
Initial release
2021-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.