stacked.offsets {hyperSpec} | R Documentation |
Calculate approriate yoffset
values for stacking in plotspc
.
stacked.offsets(x, stacked = TRUE, .spc = NULL)
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. |
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.
a list containing
offsets |
numeric with the yoffset for each group in stacked |
groups |
numeric with the group number for each spectrum |
C. Beleites
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)