Average spectra in list-column of spectra tibble (spc_tbl) by
groups given in group column.
average_spc(spc_tbl, by = "sample_id", column_in = "spc_rs")Tibble data frame containing at least the grouping column
given in argument by and input spectra given in list-column column_in.
Character vector of length 1L or name/symbol that specifies the
column by which groups of spectra are averaged. Default is "sample_id".
Character vector of length 1L or or name/symbol that
specifies the list-column that contains the inputs spectra to be averaged.
Default is "spc_rs", which are resampled spectra (i.e., resulting after
preceding resample_spc() step).
Spectra tibble data frame (class "tbl_df", "tbl", "data.frame")
with a new list-column of column name "spc_mean" at the last position,
containing mean spectra with identical row replicates within the same
by-group.
For memory efficiency and subsequent modeling, consider slicing the
extra row copies of spc_mean resulting from average_spc() for example by
split(x = spc_tbl, f = spc_tbl$<by>) %>% lapply(., function(x) x x[1, ]) %>% do.call(., rbind)
dplyr::group_by(spc_tbl, <by>) %>% dplyr::slice(1L)