eventSeries: Regular Series

View source: R/eventSeries.R

eventSeriesR 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 events.

Usage

eventSeries(times, period = "hour", which = "cumsum", begin, end,
  k.period = 1)

Arguments

times

a date-like vector corresponding to data.

period

character string that is valid input to the POSIXct method for the seq function is acceptable, specifying the spacing between successive periods. For example "year," "month," or "day."

which

a character string indicating the method to use. 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

If there is no observation during a period, then that value is set to 0 if which is "sum" or the value for the previous period if which is "cumsum." The initial value of the series is always 0.

Value

The function eventSeries returns a data frame with two columns:

DateTime

the date and time.

Sum

the sum of the number of events in the period if which is "sum."

CumSum

the cumulative sum of the number of events up to and including the period if which is "cumsum."

Examples

## Not run: 
library(smwrData)
data(QW05078470)
# Count the number of samples per month
with(QW05078470, eventSeries(DATES, "month", which="sum"))

## End(Not run)

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