recipes icon indicating copy to clipboard operation
recipes copied to clipboard

step_lag() add a datetime index parameter so that lag is not carried over gaps in non continuous time series.

Open jacekkotowski opened this issue 3 years ago • 1 comments

Feature

In situations when time series data is not continuous, e.g. in bicycle bike sharing competition by Kaggle https://www.kaggle.com/c/bike-sharing-demand/ it would be useful to have the possibility to prevent step_lag() for jumping over gaps in time series. In the case of the competition, data is missing each month after the 20th day.

e.g. step_lag(atemp, lag = 2 index_col = datetime)

There is a gap in time series (after 20th day of January, NA is returned

datetime, temp, lag_temp 2019-01-17,12, NA
2019-01-18,12, 12 2019-01-19,11, 12 2019-01-20,10, 11 2019-02-01,11, NA 2019-02-02,12, 11 2019-02-03,13, 12

jacekkotowski avatar Nov 26 '21 12:11 jacekkotowski

Can you create a reprex (a minimal reproducible example) for this feature request? The goal of a reprex is to make it easier for us to recreate your situation so that we can understand and evaluate it. Rather than downloading a large dataset from Kaggle, use some built-in or in-lined data and try to clearly outline what behavior you are seeing now vs. what you need for your use case.

If you've never heard of a reprex before, you may want to start with the tidyverse.org help page. You may already have reprex installed (it comes with the tidyverse package), but if not you can install it with:

install.packages("reprex")

Thanks! 🙌

juliasilge avatar Nov 29 '21 23:11 juliasilge

I'm closing this for inactivity. If this functionality is still requested, please file another issue!

EmilHvitfeldt avatar May 23 '24 16:05 EmilHvitfeldt

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.

github-actions[bot] avatar Jun 07 '24 00:06 github-actions[bot]