do_avg: Average spectra in a dataset

View source: R/gen_coreDataManip.r

do_avgR Documentation

Average spectra in a dataset

Description

Calculate the average spectrum of all the given spectra in a dataset, or define groups to be averaged by providing one or more class-variable.

Usage

do_avg(dataset, clv = NULL, inParallel = TRUE)

Arguments

dataset

An object of class 'aquap_data" as produced by gfd or as can be extracted from a 'cube' via getcd.

clv

Character vector, one or more valid class-variables defining the subsets of the dataset to be averaged.

inParallel

Logical, if the averaging of spectra should be done in parallel. Defaults to TRUE.

Details

The total and group-wise average spectrum is returned each in a single row with the header-data taken from the first row of the subset of the original dataset as defined by the grouping. If parameter clv is left at the default NULL, all the spectra in the dataset will be averaged together into a single row.

Value

The transformed dataset.

See Also

getcd

Other Data pre-treatment functions: [,aquap_data-method, do_addNoise(), do_blowup(), do_detrend(), do_emsc(), do_gapDer(), do_msc(), do_resampleNIR(), do_sgolay(), dpt_modules, selectWls(), ssc()

Examples

## Not run: 
fd <- gfd() # get the full dataset
fd <- selectWls(fd, 1100, 1800)
fd_avg <- do_avg(fd)
fd_avg2 <- do_avg(ssc(fd, C_water=="MQ")) # assumes the existence of column "C_water"
plot(fd_avg, pg.where="", pg.main="| averaged")
plot(fd - fd_avg, pg.where="", pg.main="| avg subtracted")
#######
fd_avg_group <- do_avg(fd, "C_Group") # averaging within groups
fd_avg_time_group <- do_avg(fd, c("C_Time", "C_Group")) # averaging within a 
# subset defined by "C_Time" and "C_Group"

## End(Not run)

bpollner/aquap2 documentation built on June 29, 2024, 5:21 p.m.