View source: R/colorSpec.interpolate.R
interpolate | R Documentation |
interpolate along a 1-parameter path of spectra
## S3 method for class 'colorSpec'
interpolate( x, p, pout, pname=deparse(substitute(p)) )
x |
a colorSpec object, typically with multiple spectra |
p |
a numeric vector with |
pout |
a numeric vector of parameter values at which interpolation of the spectra in |
pname |
the name of the parameter |
Each spectrum in x
can be thought of as a point in a high-dimensional space,
and each point has a real-valued parameter associated with it.
The function performs natural spline interpolation on these points,
one coordinate at a time.
For each wavelength value it calls spline
with method='natural'
.
interpolate(x)
returns a colorSpec object y
with a spectrum for each value in pout
.
The organization of y
is 'df.row'
,
and extradata(y)
has a single column which is a copy of pout
.
The name of the column is pname
.
The names in specnames(y)
are <pname>=<pout>
.
Other properties of y
,
e.g. wavelength
, quantity
, ...,
are the same as x
.
In case of ERROR, the function returns NULL
.
organization
,
wavelength
,
extradata
,
spline
path = system.file( "extdata/stains/PhenolRed-Fig7.txt", package="colorSpec" )
wave = 350:650
phenolred = readSpectra( path, wavelength=wave )
pH = as.numeric( sub( '[^0-9]+([0-9]+)$', '\\1', specnames(phenolred) ) )
pHvec = seq(min(pH),max(pH),by=0.05)
phenolinterp = interpolate( phenolred, pH, pHvec )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.