Wraps stats::ts() with explicit validation: the input must be a
strictly ordered, regular numeric series with no implicit missing
periods. This is the single pre-processing routine through which all
subsequent functions receive their data, so time attributes are
maintained uniformly.
Arguments
- x
A numeric vector (or an object coercible to one, including a
units-typed vector, which is coerced viaas.numeric()), or an existingts.- frequency
Number of observations per unit of time (e.g. 12 for monthly-in-years). Default 1.
- start
Time of the first observation. Default 1.
- calendar
Character tag documenting the calendar system assumed (e.g. "monthly"); recorded as an attribute, not interpreted.
- na_action
How to handle missing values (regular series require an explicit decision):
"error"(default) rejects implicit missing values;"interpolate"fills them by linear interpolation (imputation);"omit"drops them with a warning (the series is then treated as irregular).- units
Optional character unit label carried as an attribute and propagated to return values.
Examples
morie_ts(cumsum(rnorm(24)), frequency = 12, start = 2000)
#> Jan Feb Mar Apr May Jun
#> 2000 -0.19819542 0.69381297 0.66809790 0.02043745 0.66679686 0.23296412
#> 2001 -1.75296930 -1.51616563 -3.85888875 -2.89719212 -3.50161785 -4.25449513
#> Jul Aug Sep Oct Nov Dec
#> 2000 2.00557531 1.98731560 2.84013059 3.04529350 0.03724490 -1.32886704
#> 2001 -5.81010672 -7.26400046 -7.20766863 -6.69829922 -8.79618218 -9.80054416
