applyspec: apply a function to each spectrum in a colorSpec object

Description Usage Arguments Details Value See Also Examples

Description

apply a function to each spectrum in a colorSpec object

Usage

1
2
## S3 method for class 'colorSpec'
applyspec( x, FUN, ... )

Arguments

x

a colorSpec object with N wavelengths

FUN

a function that takes an N-vector as argument and returns an N-vector

...

additional arguments passed to FUN

Details

applyspec() simply calls apply() with the right MARGIN.

Value

a colorSpec object with the same dimensions, wavelength, quantity, and organization. If FUN does not return an N-vector, it is an ERROR and applyspec() returns NULL.

See Also

quantity, wavelength, linearize, organization, apply

Examples

1
2
3
4
#  convert absorbance to transmittance
path = system.file( "extdata/stains/Hematoxylin.txt", package='colorSpec' )
x = readSpectra( path )
x = applyspec( x, function(y) {10^(-y)} ) # this is what linearize(x) does

Example output

This is colorSpec.  Version: 0.8-3.  Author: Glenn Davis [aut, cre].  Built: R 3.4.4; ; 2019-05-11 03:46:31 UTC; unix

colorSpec documentation built on June 24, 2019, 9:03 a.m.