Skip to contents

Builds the object every ts_*() verb takes: an ordered collection of (date, value) ordinates on a stated time interval, mirroring the Numerics TimeSeries container.

Usage

time_series(dates, values, interval = "one_day")

Arguments

dates

the ordinate dates.

values

the ordinate values, one per date.

interval

one of ts_interval_names(). Default "one_day".

Value

a corehydro_ts object.

Details

dates may be POSIXct, Date, ISO 8601 character strings, or numeric seconds since 1970-01-01; they are carried as UTC POSIXct and returned that way. Missing observations are NA (or NaN) in values and stay missing through every verb that says so.

The interval is not merely a label: it is what ts_shift(by = "start") walks, what ts_peaks_over_threshold() measures its independence criterion in, and what ts_convert_interval() converts from. "irregular" is the right choice for an event series (annual maxima, peaks over threshold) whose spacing is not fixed.

See also

ts_block_series() for annual maxima, ts_peaks_over_threshold() for a POT series, ts_statistics() for a summary.

Examples

ts <- time_series(as.Date("2000-01-01") + 0:9, c(3, 1, 4, 1, 5, 9, 2, 6, 5, 3))
ts
#> <corehydro_ts> 10 ordinates, interval "one_day"
#>   2000-01-01 to 2000-01-10
#>   2000-01-01  3
#>   2000-01-02  1
#>   2000-01-03  4
#>   2000-01-04  1
#>   2000-01-05  5
#>   ... 5 more