apply | R Documentation |
hyperSpec
object.apply
gives the functionality of apply
for
hyperSpec
objects.
## S4 method for signature 'hyperSpec'
apply(
X,
MARGIN,
FUN,
...,
label.wl = NULL,
label.spc = NULL,
new.wavelength = NULL,
simplify
)
X , spc |
a |
MARGIN |
The subscript which the function will be applied over.
If |
FUN |
function to compute the summary statistics |
... |
further arguments passed to |
label.wl , label.spc |
new labels for wavelength and spectral intensity axes |
new.wavelength |
for |
simplify |
ignored: apply for hyperSpec results are always simplified |
The generic functions of group Math
are not definded
for hyperSpec
objects. Instead, apply
can be used. For
functions like log
that work on scalars, MARGIN = 1 : 2
gives
the appropriate behaviour.
spcapply
does the same as apply
with MARGIN = 1
, but
additionally allows to set a new wavelength axis and adjust the labels.
wlapply
does the same as apply
with MARGIN = 2
, but
additionally allows to set a new wavelength axis and adjust the labels.
A hyperSpec
object
C. Beleites
apply
, for applying FUN
to subgroups of
the hyperSpec
object: aggregate
.
plotspc (apply (chondro, 2, range))
avgflu <- apply (flu, 1, mean,
label.spc = expression (bar (I)),
new.wavelength = mean (wl (flu)))
avgflu
flu[[,,405:407]]
apply (flu, 1:2, "*", -1)[[,,405:407]]
## without MARGIN the whole matrix is handed to FUN
apply (flu [,,405:407], , print) [[]]
## whereas MARGIN = 1 : 2 leads to FUN being called for each element separately
apply (flu [,,405:407], 1 : 2, print) [[]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.