stacked.offsets {hyperSpec}R Documentation

y Offsets for Stacked Plots

Description

Calculate approriate yoffset values for stacking in plotspc.

Usage

stacked.offsets(x, stacked = TRUE, .spc = NULL)

Arguments

x a hyperSpec object
stacked TRUE to stack single spectra. A numeric or factor is interpreted as giving the grouping, a character is interpreted as the name of the extra data column of x that holds the grouping.
.spc for internal use. If given, the ranges are evaluated on .spc. However, this may change in future.

Details

Usually, the stacked argument of plotspc will do fine, but if you need fine control over the stacking, you may calculate the y offsets yourself.

Value

a list containing

offsets numeric with the yoffset for each group in stacked
groups numeric with the group number for each spectrum

Author(s)

C. Beleites

See Also

plotspc

Examples

groups <- rep (1 : 3, length.out = nrow (chondro))
mean.pm.sd <- aggregate (chondro, groups, 
   function (x) mean (x) + c(-1, 1) * sd (x))

offset <- stacked.offsets (mean.pm.sd, ".aggregate")
plot (mean.pm.sd, fill.col = matlab.palette (3), fill = ".aggregate", stacked = ".aggregate")
        
plot (aggregate (chondro, groups, mean), yoffset = offset$offsets,      lines.args = list (lty = 2, lwd = 2), add = TRUE)

[Package hyperSpec version 0.95 Index]