agg.fluxes {gasfluxes} | R Documentation |
Accumulation of fluxes
Description
Aggregate a time series of fluxes to a cummulative flux value.
Usage
agg.fluxes(fluxes, datetimes, timeunit = "hours")
Arguments
fluxes |
flux values |
datetimes |
datetime values (POSIXct or POSIXlt) |
timeunit |
the unit of time (denominator of the flux unit), supported are the explicit units supported by |
Details
The function uses linear interpolation. The unit of the cumulative flux is [fluxes] * timeunit. NA values are removed and values sorted according to time order. If less then two non-NA value pairs are provided, NA is returned for the cumlative flux.
Value
A one-row data.frame with columns
flux |
the cumulative flux |
from |
the start of the cumulation period |
to |
the end of the cumulation period |
The return value being a data.frame is useful, when the function is used for "split-apply-combine" type operations to calculate groupwise cumulated values, e.g., using package data.table.
Examples
#Some random example data
datetimes <- Sys.time() + (1:20)/2*24*3600
set.seed(42)
fluxes <- rlnorm(20, 5)
agg.fluxes(fluxes, datetimes)