View source: R/transform_spectra.R
aggregate.spectra | R Documentation |
Applies FUN (and FUN_meta) over spectra aggregating by factor 'by'.
## S3 method for class 'spectra' aggregate(x, by, FUN, FUN_meta = NULL, ...)
x |
spectra object |
by |
vector of factors to guide the aggregation |
FUN |
function to be applied to value (and meta if FUN_meta is NULL) |
FUN_meta |
function to be applied to metadata. If NULL (default), same FUN applied to value is used. |
... |
extra args to FUN |
Argument FUN_meta is useful if you want to apply a different function to
metadata and value. If you want to aggregate spectra and metadata
using 'mean', 'sd', 'median' etc. but try to keep the text values, wrap your
function in try_keep_txt(f)
.
spectra object
Jose Eduardo Meireles
library(spectrolab) spec = as_spectra(spec_matrix_example, name_idx = 1) spec_mean = aggregate(spec, by = names(spec), mean, try_keep_txt(mean))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.