Learn R Programming

hyperSpec (version 0.95)

stacked.offsets: 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.

Value

  • a list containing
  • offsetsnumeric with the yoffset for each group in stacked
  • groupsnumeric with the group number for each spectrum

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.

See Also

plotspc

Examples

Run this code
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)

Run the code above in your browser using DataLab