get_last_n_obs.Rd
Get last high frequency observations
get_last_n_obs(hf_data, lf_date, n_lags = 1, one_row = TRUE)
hf_data | high frequency data |
---|---|
lf_date | low frequency date |
n_lags | number of lags to add |
one_row | output representation |
tsibble with high frequency lags added
Get last high frequency observations. The function cuts n_lags observations from the table hf_data, that are from the same day or before as the date indicated by lf_date. If one_row is TRUE the result is stacked in a row, otherwise the result is a column.
hf_data <- tibble::tibble(date = lubridate::ymd("2011-01-01") + lubridate::days(0:60), observations = rnorm(61)) get_last_n_obs(hf_data, "2011-02-23", n_lags = 7, one_row = FALSE)#> # A tibble: 7 x 2 #> hf_date observations #> <date> <dbl> #> 1 2011-02-17 -0.509 #> 2 2011-02-18 -1.74 #> 3 2011-02-19 0.0405 #> 4 2011-02-20 -0.124 #> 5 2011-02-21 -0.613 #> 6 2011-02-22 0.161 #> 7 2011-02-23 -0.662