@@ -113,19 +113,21 @@ epix_as_of <- function(x, version, min_time_value = -Inf, all_versions = FALSE,
113
113
if (all_versions ) {
114
114
# epi_archive is copied into result, so we can modify result directly
115
115
result <- epix_truncate_versions_after(x , version )
116
- result $ DT <- result $ DT [time_value > = .min_time_value , ] # nolint: object_usage_linter
116
+ if (! identical(.min_time_value , - Inf )) {
117
+ # See below for why we need this branch.
118
+ result $ DT <- result $ DT [time_value > = .min_time_value , ] # nolint: object_usage_linter
119
+ }
117
120
return (result )
118
121
}
119
122
120
123
# Make sure to use data.table ways of filtering and selecting
121
- if (identical(.min_time_value , - Inf )) {
124
+ as_of_epi_df <- if (identical(.min_time_value , - Inf )) {
122
125
# This branch is needed for `epix_as_of` to work with `yearmonth` time type
123
126
# to avoid time_value > .min_time_value, which is NA for `yearmonth`.
124
- filter_mask <- version < = .version
127
+ x $ DT [ version < = .version , ]
125
128
} else {
126
- filter_mask <- time_value > = .min_time_value & version < = .version
127
- }
128
- as_of_epi_df <- x $ DT [filter_mask , ] %> % # nolint: object_usage_linter
129
+ x $ DT [time_value > = .min_time_value & version < = .version , ]
130
+ } %> % # nolint: object_usage_linter
129
131
unique(by = c(" geo_value" , " time_value" , other_keys ), fromLast = TRUE ) %> %
130
132
tibble :: as_tibble() %> %
131
133
dplyr :: select(- " version" ) %> %
0 commit comments