Closed stribstrib closed 5 years ago
Thank you for this detailed and very well-explained issue.
I cannot remember exactly why I chose to implement it in this way. I think I looked for rounding down and rounding up being complementary. But from your example it indeed makes sense to round to equal or larger, when rounding up as well. I will think about how to include that option, while keeping the function backwards compatible (meaning that it is possible, but not the default).
Thanks again.
I've recently run into an issue rounding up with
thicken()
, and am wondering if another rounding option could be added, or perhaps a solution exists elsewhere withinpadr
.Some sample data with a base time interval of 15 minutes:
When rounding down to the nearest hour, thicken maps the input variable to the closest spanned variable less than or equal to itself. For records that land directly on the hour interval, the timestamps match. This makes intuitive sense to me.
For rounding up to the nearest hour, records that land directly on the hour interval are mapped to one full interval ahead of their original timestamp. This surprised me, and seems counter-intuitive. I did see that this was explained in the padr implementation vignette, where it's specifies that rounding up maps the input variable to the closest value greater than (but not equal to) itself.
Instead, I'm hoping for a way to use
thicken()
and get results like this:This method of rounding up that I'm looking for is in keeping with the way dataloggers (at least those I'm familiar with) summarize their time series data, where timestamps represent the end of the period summarized. In this sample data for instance, the record with an original timestamp of 17:00:00 (row 5) represents a summary of data collected between 16:45:01 and 17:00:00. Linking these data to a timestamp of 18:00:00 would be a significant misrepresentation of when the data was actually collected.
Would it be possible to create a rounding option that would map the input value to the nearest interval greater than or equal to itself?
** Brand new to github, so apologies if I over-explained or committed some other gaffe.