File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -475,11 +475,13 @@ guess_time_type <- function(time_value, time_value_arg = rlang::caller_arg(time_
475
475
if (inherits(time_value , " Date" )) {
476
476
unique_time_gaps <- as.numeric(diff(sort(unique(time_value ))))
477
477
# Gaps in a weekly date sequence will cause some diffs to be larger than 7
478
- # days, so check modulo 7 equality, rather than equality with 7.
479
- if (all(unique_time_gaps %% 7 == 0 )) {
478
+ # days, so check modulo 7 equality, rather than equality with 7. The length
479
+ # check is there so that we don't classify epi_df with a single data point
480
+ # per geo as "week".
481
+ if (all(unique_time_gaps %% 7 == 0 ) && length(unique_time_gaps ) > 0 ) {
480
482
return (" week" )
481
483
}
482
- if (all(unique_time_gaps > = 28 )) {
484
+ if (all(unique_time_gaps > = 28 ) && length( unique_time_gaps ) > 0 ) {
483
485
cli_abort(
484
486
" Found a monthly or longer cadence in the time column `{time_value_arg}`.
485
487
Consider using tsibble::yearmonth for monthly data and 'YYYY' integers for year data."
You can’t perform that action at this time.
0 commit comments