agg.fluxes | R Documentation |
Aggregate a time series of fluxes to a cummulative flux value.
agg.fluxes(fluxes, datetimes, timeunit = "hours")
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 |
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.
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.
#Some random example data
datetimes <- Sys.time() + (1:20)/2*24*3600
set.seed(42)
fluxes <- rlnorm(20, 5)
agg.fluxes(fluxes, datetimes)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.