regularSeries: Regular Series

View source: R/regularSeries.R

regularSeriesR Documentation

Regular Series

Description

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.

Usage

regularSeries(x, times, period = "month", which = "middle", begin, end,
  k.period = 1)

Arguments

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 seq is acceptable, specifying the spacing between successive periods. For example "year," "month," or "day."

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 period in each period of the output series.

Details

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.

Value

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 x for the corresponding season number.

ValueDate

the date from times for the corresponding season number if which was one of "earliest," "middle," or "latest"; otherwise missing.

Examples

## 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)

USGS-R/smwrBase documentation built on Oct. 18, 2022, 9:55 a.m.