View source: R/transform_spectra.R
apply_by_band | R Documentation |
apply_by_band
is conceptually similar to apply(as.matrix(x), 2, fun),
but returns a spectra object while dealing with metadata and attributes.
Applying a function that does not act on numeric values may crash the function
or render all values NA.
apply_by_band(x, fun, na.rm = TRUE, keep_txt_meta = TRUE, name = NULL, ...) ## S3 method for class 'spectra' apply_by_band(x, fun, na.rm = TRUE, keep_txt_meta = TRUE, name = NULL, ...)
x |
spectra |
fun |
numeric function to be applied to each band. |
na.rm |
boolean. remove NAs? |
keep_txt_meta |
boolean. try to keep text in the metadata? |
name |
name for each sample in the output spectra. The default (NULL) will give samples sequential numeric names. Recycled if necessary. |
... |
extra arguments passed to fun |
spectra
apply_by_band(spectra)
: Apply a numeric function by band
Jose Eduardo Meireles
library(spectrolab) spec = as_spectra(spec_matrix_example, name_idx = 1) spec_mean = apply_by_band(spec, mean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.