-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
Identified in tidyverts/fable#396
library(tsibble)
#> Registered S3 method overwritten by 'tsibble':
#> method from
#> as_tibble.grouped_df dplyr
#>
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, union
# Works: integer index, but no column named `int`
x_ok <- tsibble(
time = 1:5,
value = c(10, 20, NA, 40, 50),
index = time
)
scan_gaps(x_ok)
#> # A tsibble: 0 x 1 [?]
#> # ℹ 1 variable: time <int>
has_gaps(x_ok)
#> # A tibble: 1 × 1
#> .gaps
#> <lgl>
#> 1 FALSE
# Fails / misbehaves: same data, but with a column named `int`
x_bug <- tsibble(
time = 1:5,
value = c(10, 20, NA, 40, 50),
int = 1L, # problematic name
index = time
)
x_bug
#> # A tsibble: 5 x 3 [1]
#> time value int
#> <int> <dbl> <int>
#> 1 1 10 1
#> 2 2 20 1
#> 3 3 NA 1
#> 4 4 40 1
#> 5 5 50 1
scan_gaps(x_bug) # error / unexpected result
#> Error in `summarise()`:
#> ℹ In argument: `time = list2(`:=`("time", seq_generator(time, int)))`.
#> ℹ In group 1: .
#> Caused by error in `if (time_units == 0) ...`:
#> ! the condition has length > 1
has_gaps(x_bug) # error / unexpected result
#> Error in `summarise()`:
#> ℹ In argument: `.gaps = (length(seq_generator(time, int)) -
#> length(time)) > 0`.
#> ℹ In group 1: .
#> Caused by error in `if (time_units == 0) ...`:
#> ! the condition has length > 1Created on 2026-01-15 with reprex v2.1.1
Metadata
Metadata
Assignees
Labels
No labels