R/bandSpectra.R

bandSpectra <- function(spectra,  breaks = NULL, labels = NULL, ...){
    ## convert breaks to frequency bands
    freq <- as.numeric(colnames(spectra))
    breaks <- c(floor(min(freq - 1, 0)), breaks, ceiling(max(freq) + 1))
    bands <- cut(freq, breaks = breaks, labels = labels, ...)   
    
    ## total power in each band
    t(rowsum(t(spectra), bands, reorder = FALSE, na.rm = TRUE))
}

Try the gslcca package in your browser

Any scripts or data that you put into this service are public.

gslcca documentation built on May 2, 2019, 5:46 p.m.