View source: R/mts_summarize.R
mts_summarize | R Documentation |
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.
mts_summarize(
mts,
timezone = NULL,
unit = c("day", "week", "month", "year"),
FUN = NULL,
...,
minCount = NULL
)
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 |
An mts time series object containing daily (or other)
statistical summaries.
(A list with meta
and data
dataframes.)
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.
library(MazamaTimeSeries)
daily <-
mts_summarize(
mts = Carmel_Valley,
timezone = NULL,
unit = "day",
FUN = mean,
na.rm = TRUE,
minCount = 18
)
# Daily means
head(daily$data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.