Skip to content

Commit 41a6a5c

Browse files
author
admin
committed
Fixed filtering
1 parent 63694c4 commit 41a6a5c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

R/archive.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ epi_archive =
189189
#' @description Generates a snapshot in `epi_df` format as of a given version.
190190
#' See the documentation for the wrapper function `epix_as_of()` for details.
191191
#' @importFrom data.table between key
192-
as_of = function(max_version) {
192+
as_of = function(max_version, min_time_value = -Inf) {
193193
# Self max version and other keys
194194
self_max = max(self$DT$version)
195195
other_keys = setdiff(key(self$DT),
@@ -213,7 +213,8 @@ epi_archive =
213213
# Filter by version and return
214214
return(
215215
# Make sure to use data.table ways of filtering and selecting
216-
self$DT[version <= max_version, ] %>%
216+
self$DT[time_value >= min_time_value &
217+
version <= max_version, ] %>%
217218
unique(by = c("geo_value", "time_value", other_keys),
218219
fromLast = TRUE) %>%
219220
tibble::as_tibble() %>%

R/methods-epi_archive.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
#'
3535
#' # no warning shown
3636
#' epix_as_of(archive_cases_dv_subset, max_version = as.Date("2020-06-10"))
37-
epix_as_of = function(x, max_version) {
37+
epix_as_of = function(x, max_version, min_time_value = -Inf) {
3838
if (!inherits(x, "epi_archive")) Abort("`x` must be of class `epi_archive`.")
39-
return(x$as_of(max_version))
39+
return(x$as_of(max_version, min_time_value))
4040
}
4141

4242
#' Merge two `epi_archive` objects

0 commit comments

Comments
 (0)