Learn R Programming

ChemoSpec (version 5.3.21)

plotSpectraDist: Plot the Distance Between Spectra and a Reference Spectrum in a Spectra Object

Description

This function plots the distance between a reference spectrum and all other spectra in a Spectra object. Distance can be defined in a number of ways (see Arguments).

Usage

plotSpectraDist(spectra, method = "pearson", ref = 1, labels = TRUE, ...)

Arguments

spectra

An object of S3 class Spectra.

method

Character. Any method acceptable to rowDist.

ref

Integer. The spectrum to be used as a reference.

labels

Logical. Shall the points be labeled?

Plot parameters to be passed to the plotting routines.

Value

A data frame containing the data plotted (sample names, sample colors, distances).

See Also

To compare all spectra simultaneously in a heatmap, see sampleDist. Additional documentation at https://bryanhanson.github.io/ChemoSpec/

Examples

Run this code
# NOT RUN {
data(SrE.NMR)
txt1 <- paste("Distance from", SrE.NMR$names[1]) # capture before padding
txt2 <- paste("Rank Distance from", SrE.NMR$names[1])
SrE.NMR$names <- paste("  ", SrE.NMR$names, sep = "") # pad the names for better appearance
temp <- plotSpectraDist(SrE.NMR,
  xlab = txt2, ylab = txt1, main = txt1,
  ylim = c(0, 1.1), xlim = c(0, 16), srt = 45
)
# }

Run the code above in your browser using DataLab