-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmts_summarize.Rd
70 lines (60 loc) · 1.95 KB
/
mts_summarize.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mts_summarize.R
\name{mts_summarize}
\alias{mts_summarize}
\title{Create summary time series for an \emph{mts} time series object}
\usage{
mts_summarize(
mts,
timezone = NULL,
unit = c("day", "week", "month", "year"),
FUN = NULL,
...,
minCount = NULL
)
}
\arguments{
\item{mts}{\emph{mts} object.}
\item{timezone}{Olson timezone used to interpret dates.}
\item{unit}{Unit used to summarize by (\emph{e.g.} "day").}
\item{FUN}{Function used to summarize time series.}
\item{...}{Additional arguments to be passed to \code{FUN}
(_e.g._ \code{na.rm = TRUE}).}
\item{minCount}{Minimum number of valid data records required to calculate
summaries. Time periods with fewer valid records will be assigned \code{NA}.}
}
\value{
An \emph{mts} time series object containing daily (or other)
statistical summaries.
(A list with \code{meta} and \code{data} dataframes.)
}
\description{
Individual time series in \code{mts$data} are grouped by \code{unit} and then
summarized using \code{FUN}.
The most typical use case is creating daily averages where each day begins at
midnight. This function interprets times using the \code{mts$data$datetime}
\code{tzone} attribute so be sure that is set properly.
Day boundaries are calculated using the specified \code{timezone} or, if
\code{NULL}, the most common (hopefully only!) time zone found in
\code{mts$meta$timezone}. Leaving \code{timezone = NULL}, the default,
results in "local time" date filtering which is the most common use case.
}
\note{
Because the returned \emph{mts} object is defined on a daily axis in a
specific time zone, it is important that the incoming \code{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)
}