powered by
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
apply_by_band(x, fun, na.rm = TRUE, keep_txt_meta = TRUE, name = NULL, ...)# S3 method for spectra apply_by_band(x, fun, na.rm = TRUE, keep_txt_meta = TRUE, name = NULL, ...)
# S3 method for spectra apply_by_band(x, fun, na.rm = TRUE, keep_txt_meta = TRUE, name = NULL, ...)
spectra
numeric function to be applied to each band.
boolean. remove NAs?
boolean. try to keep text in the metadata?
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
apply_by_band(spectra): Apply a numeric function by band
apply_by_band(spectra)
Jose Eduardo Meireles
library(spectrolab) spec = as_spectra(spec_matrix_example, name_idx = 1) spec_mean = apply_by_band(spec, mean)
Run the code above in your browser using DataLab