scale: Center and scale hyperSpec object

Description Usage Arguments Details Value Author(s) See Also Examples

Description

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

Usage

1
2
## S4 method for signature '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 as.matrix (e.g. hyperSpec object containing 1 spectrum) can specify the center spectrum.

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 as.matrix (e.g. hyperSpec object containing 1 spectrum) can specify the center spectrum.

Details

Package scale provides a fast alternative for base::scale

Value

the centered & scaled hyperSpec object

Author(s)

C. Beleites

See Also

scale

package scale.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## 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)

Example output

Loading required package: lattice
Loading required package: grid
Loading required package: ggplot2
Loading required package: xml2
Package hyperSpec, version 0.99-20200527

To get started, try
   vignette ("hyperspec")
   package?hyperSpec 
   vignette (package = "hyperSpec")

If you use this package please cite it appropriately.
   citation("hyperSpec")
will give you the correct reference.

The project homepage is http://hyperspec.r-forge.r-project.org

hyperSpec documentation built on May 2, 2019, 5:45 p.m.