Learn R Programming

hyperSpec (version 0.98-20140523)

scale,hyperSpec-method: Center and scale hyperSpec object

Description

link[base]{scale}s the spectra matrix. scale (x, scale = FALSE) centers the data.

Usage

## S3 method for class 'hyperSpec':
scale(x, center = TRUE,
    scale = TRUE)

Arguments

x
the hyperSpec object
center
if TRUE, the data is centered to colMeans (x), FALSE suppresses centering. Alternatively, an object that can be converted to numeric of length nwl (x) by
scale
if TRUE, the data is scaled to have unit variance at each wavelength, FALSE suppresses scaling. Alternatively, an object that can be converted to numeric of length nwl (x) by

Value

  • the centered & scaled hyperSpec object

Details

Package scale provides a fast alternative for base::scale

See Also

scale

package scale.

Examples

Run this code
## mean center & variance scale
tmp <- scale (chondro)
plot (tmp, "spcmeansd")
plot (sample (tmp, 5), add = TRUE, col = 2)

## mean center only
tmp <- scale (chondro, scale = FALSE)
plot (tmp, "spcmeansd")
plot (sample (tmp, 5), add = TRUE, col = 2)

## custom center
tmp <- sweep (chondro, 1, mean, `/`)
plot (tmp, "spcmeansd")
tmp <- scale (tmp, center = quantile (tmp, .05), scale = FALSE)

Run the code above in your browser using DataLab