| mts_summarize {MazamaTimeSeries} | R Documentation |
Create summary time series for an mts time series object
Description
Individual time series in mts$data are grouped by unit and then
summarized using FUN.
The most typical use case is creating daily averages where each day begins at
midnight. This function interprets times using the mts$data$datetime
tzone attribute so be sure that is set properly.
Day boundaries are calculated using the specified timezone or, if
NULL, the most common (hopefully only!) time zone found in
mts$meta$timezone. Leaving timezone = NULL, the default,
results in "local time" date filtering which is the most common use case.
Usage
mts_summarize(
mts,
timezone = NULL,
unit = c("day", "week", "month", "year"),
FUN = NULL,
...,
minCount = NULL
)
Arguments
mts |
mts object. |
timezone |
Olson timezone used to interpret dates. |
unit |
Unit used to summarize by (e.g. "day"). |
FUN |
Function used to summarize time series. |
... |
Additional arguments to be passed to |
minCount |
Minimum number of valid data records required to calculate
summaries. Time periods with fewer valid records will be assigned |
Value
An mts time series object containing daily (or other)
statistical summaries.
(A list with meta and data dataframes.)
Note
Because the returned mts object is defined on a daily axis in a
specific time zone, it is important that the incoming mts contain
timeseries associated with a single time zone.
Examples
library(MazamaTimeSeries)
daily <-
mts_summarize(
mts = Carmel_Valley,
timezone = NULL,
unit = "day",
FUN = mean,
na.rm = TRUE,
minCount = 18
)
# Daily means
head(daily$data)