Replace date or time values by the first of the period. tsbox usually relies on timestamps being the first value of a period.

ts_first_of_period(x)

Arguments

x

ts-boxable time series, an object of class ts, xts, zoo, data.frame, data.table, tbl, tbl_ts, tbl_time, tis, irts or timeSeries.

Value

a ts-boxable object of the same class as x, i.e., an object of class ts, xts, zoo, data.frame, data.table, tbl, tbl_ts, tbl_time, tis, irts or timeSeries.

Examples

x <- ts_c( a = ts_lag(ts_df(mdeaths), "14 days"), b = ts_lag(ts_df(mdeaths), "-2 days") ) ts_first_of_period(x)
#> [1] id time value #> <0 rows> (or 0-length row.names)
ts_first_of_period(ts_lag(ts_df(austres), "14 days"))
#> [1] time value #> <0 rows> (or 0-length row.names)
# \donttest{ x <- ts_lag(data.frame( time = seq(as.POSIXct("1970-01-01"), length.out = 10, by = "10 sec"), value = rnorm(10) ), "3 sec") ts_first_of_period(x)
#> Warning: no non-missing arguments to max; returning -Inf
#> Error in max(which(time <= smry$start)):min(which(time >= smry$end)): result would be too long a vector
# }