Open mooibroekd opened 2 weeks ago
Hello Dennis, I am happy to have a look at this, but it will have to wait for a couple of weeks because I am travelling. I would recommend developing a work around for now because of the delay. Enjoy and I will come back to this when I can.
The current method applied in
detect_date_interval
implicitly assumes a data structure ordered byvariable
first, and within the variable bydate
.The function fails to determine the interval when the data is ordered first by
date
, and within this date byvariable
(as illustrated below):Note that in this case the
dplyr::lag
function will produce a lot of 0's as there is no lag between the first 7 rows. That also means that thethreadr::mode_average
function will report 0 as the outcome, ultimately leading to anunknown
interval being (falsely) reported.The easiest way to fix this is by probably removing all 0 values for the
seconds
. If the number of rows inseconds
after removal is also zero, then the user provided data without any date interval.Alternatively, when selecting the dates this can be done on the
unique
set of dates in the dataframe, possibly ordering them after selecting them to prevent further issues.