Aggregate a metabolism attribute from swmpr data by a specified time period and method
Usage
aggremetab(swmpr_in, ...)
# S3 method for class 'swmpr'
aggremetab(swmpr_in, by = "weeks", na.action = na.pass, alpha = 0.05, ...)
Arguments
- swmpr_in
input swmpr object
- ...
additional arguments passed to other methods
- by
chr string or numeric value specifying aggregation period. If chr string, must be
'years'
,'quarters'
,'months'
,'weeks'
,'days'
, or'hours'
. A numeric value indicates the number of days for a moving window average. Additional arguments passed tosmoother
can be used ifby
is numeric.- na.action
function for treating missing data, default
na.pass
- alpha
numeric indicating alpha level of confidence interval for aggregated data
Value
Returns an aggregated metabolism data.frame
if the metabolism
attribute of the swmpr object is not NULL
. Upper and lower confidence limits are also provided if the aggregation period was specified as a character string.
Details
The function summarizes metabolism data by averaging across set periods of observation. Confidence intervals are also returned based on the specified alpha level. It is used within plot_metab
function to view summarized metabolism results. Data can be aggregated by 'years'
, 'quarters'
, 'months'
, or 'weeks'
for the supplied function, which defaults to the mean
. The method of treating NA values for the user-supplied function should be noted since this may greatly affect the quantity of data that are returned.
Examples
if (FALSE) { # \dontrun{
## import water quality and weather data
data(apadbwq)
data(apaebmet)
## qaqc, combine
wq <- qaqc(apadbwq)
met <- qaqc(apaebmet)
dat <- comb(wq, met)
## estimate metabolism
res <- ecometab(dat)
## change aggregation period and alpha
aggremetab(res, by = 'months', alpha = 0.1)
## use a moving window average of 30 days
aggremetab(res, by = 30)
## use a left-centered window instead
aggremetab(res, by = 30, sides = 1)
} # }