Skip to content

Commit 1899c49

Browse files
committed
refactor(epi_slide_opt): cleaner subresult formation
We can remove some level of call nesting by using existing new_tibble(vec_recycle_common()) rather than vec_cbind() to incorporate the group_key. (While we weren't triggering this behavior, `vec_cbind()` has some ptype rules that are probably not what we want if `epi_df`s were to be involved, so hopefully this will also prevent future re-use in a situation where that might have been the case.)
1 parent e9c8ccd commit 1899c49

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ importFrom(utils,capture.output)
249249
importFrom(utils,tail)
250250
importFrom(vctrs,"vec_slice<-")
251251
importFrom(vctrs,vec_cast)
252-
importFrom(vctrs,vec_cbind)
253252
importFrom(vctrs,vec_data)
254253
importFrom(vctrs,vec_duplicate_any)
255254
importFrom(vctrs,vec_equal)

R/epiprocess-package.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#' @importFrom rlang is_bare_integerish
3030
#' @importFrom tools toTitleCase
3131
#' @importFrom vctrs vec_cast
32-
#' @importFrom vctrs vec_cbind
3332
#' @importFrom vctrs vec_data
3433
#' @importFrom vctrs vec_equal
3534
#' @importFrom vctrs vec_in

R/slide.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -342,18 +342,18 @@ epi_slide_one_group <- function(
342342
all_dates <- .date_seq_list$all_dates
343343
missing_times <- all_dates[!vec_in(all_dates, .data_group$time_value)]
344344
.data_group <- reclass(vec_rbind(
345-
.data_group, # (epi_df; epi_slide uses .keep = TRUE)
346-
vec_cbind( # (tibble -> vec_rbind produces tibble)
347-
.group_key,
348-
new_tibble(vec_recycle_common(
349-
time_value = c(
350-
missing_times,
351-
.date_seq_list$pad_early_dates,
352-
.date_seq_list$pad_late_dates
353-
),
354-
.real = FALSE
355-
))
356-
)
345+
.data_group,
346+
# (^ epi_df; epi_slide uses .keep = TRUE)
347+
# (v tibble -> vec_rbind outputs tibble)
348+
new_tibble(vec_recycle_common(
349+
!!!.group_key,
350+
time_value = c(
351+
missing_times,
352+
.date_seq_list$pad_early_dates,
353+
.date_seq_list$pad_late_dates
354+
),
355+
.real = FALSE
356+
))
357357
# we should be adding time values of the same time_type (and shouldn't be
358358
# introducing duplicate epikeytime values); we can reclass without checks:
359359
), attr(.data_group, "metadata")) %>%

0 commit comments

Comments
 (0)