Learn R Programming

hsdar (version 0.5.1)

apply.Speclib: Apply function for class Speclib

Description

Apply function over all spectra or a subset of spectra

Usage

"apply"(X, FUN, byattributes = NULL, ...)

Arguments

X
Object of class Speclib
FUN
Function to be applied. Matched with match.fun.
byattributes
Character string giving the name of the column in the attributes to be used as subsets to apply function FUN on.
...
Further arguments passed to FUN.

Value

Object of class Speclib.

See Also

apply, match.fun, Speclib

Examples

Run this code
data(spectral_data)

mean_spectrum <- apply(spectral_data, FUN = mean)
plot(mean_spectrum)

## Same as above but seperately for both seasons
mean_spectra <- apply(spectral_data, FUN = mean, byattributes = "season")
plot(mean_spectra, FUN = 1, ylim = c(0,50))
plot(mean_spectra, FUN = 2, new = FALSE)
attribute(mean_spectra)

Run the code above in your browser using DataLab