View source: R/regularSeries.R
regularSeries | R Documentation |
Some time-series analyses require data that are uniformly spaced in time. This function will construct a regular series from randomly spaced data using any of several user-definable methods.
regularSeries(x, times, period = "month", which = "middle", begin, end, k.period = 1)
x |
a vector of observations that represents a series. |
times |
a date-like vector corresponding to data. |
period |
character string that is valid input to the POSIXct method
for the function |
which |
a character string indicating the method to use, or the name of a function. See Details for options. |
begin |
the beginning date as POSIXt or as character. |
end |
the end date as POSIXt or as character. |
k.period |
the number of units of |
For regularSeries
, if there is no observation during a period, then that
value is set to NA
. If there is one observation, then the value is set
to the value of that single observation. The value of which
controls how
periods with multiple observations are handled. Three character strings are
recognized for selecting a single value: "earliest" selects the earliest
observation in the period, "middle" selects the observation closest to the
middle of the period, and "latest" selects the latest observation in the
period. If which
is not one of these, then it should be the name of a
function such as mean or median.
The function regularSeries
returns a data frame with the
following columns:
Season |
the season number. |
SeasonStartDate |
the starting date of the corresponding season number—the season includes dates greater than or equal to this date. |
SeasonEndDate |
the end date of the corresponding season number—the season includes dates strictly less than this date. |
Value |
the value from |
ValueDate |
the date from |
## Not run: library(smwrData) data(QW05078470) with(QW05078470, regularSeries(P00665, DATES)) # there should be no values for season numbers 2, 5, or 10 ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.