-
Notifications
You must be signed in to change notification settings - Fork 420
Open
Labels
featurea feature request or enhancementa feature request or enhancement
Description
Right now you just get an error
> tidyr::full_seq(c(1, Inf), 1L)
Error in if (any(((x - rng[1])%%period > tol) & (period - (x - rng[1])%%period > :
missing value where TRUE/FALSE neededYou most likely don't want to create an infinite sequence anyways.
This would be somewhat useful with the Date method in particular, as a way to generate a full sequence along the following start/end intervals:
start <- as.Date(c("2019-01-05", "2019-01-10", "2019-01-11", "2019-01-14"))
end <- as.Date(c("2019-01-07", NA, "2019-01-14", NA))
end[is.na(end)] <- Inf
# `end = Inf` means "hasn't ended yet"
df <- tibble::tibble(start = start, end = end)
df
#> # A tibble: 4 × 2
#> start end
#> <date> <date>
#> 1 2019-01-05 2019-01-07
#> 2 2019-01-10 Inf
#> 3 2019-01-11 2019-01-14
#> 4 2019-01-14 Inf
# Want a full sequence along range of start/end excluding infinite values
# `finite = TRUE` gives you the right range
range <- .Date(range(as.numeric(c(df$start, df$end)), finite = TRUE))
range
#> [1] "2019-01-05" "2019-01-14"
seq(range[1], range[2], by = 1)
#> [1] "2019-01-05" "2019-01-06" "2019-01-07" "2019-01-08" "2019-01-09"
#> [6] "2019-01-10" "2019-01-11" "2019-01-12" "2019-01-13" "2019-01-14"
# Ideally you'd just do:
# tidyr::full_seq(c(start, end), period = 1)Created on 2023-04-28 with reprex v2.0.2.9000
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancement