Skip to content

Commit adbdcd4

Browse files
committed
use reclass fn instead of bind_rows
1 parent d04066a commit adbdcd4

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

R/slide.R

+10-11
Original file line numberDiff line numberDiff line change
@@ -291,23 +291,22 @@ epi_slide <- function(x, f, ..., before, after, ref_time_values,
291291

292292
key_cols_no_time <- kill_time_value(key_cols)
293293

294-
# `complete` strips epi_df format and metadata. Restore them.
295-
x <- bind_rows(
296-
x[c(),],
297-
# Add in rows for each present key column combination for all dates.
298-
# - This happens within each group if the data is grouped. This
299-
# doesn't change the impact of completion because we apply the
300-
# computation by group as well.
301-
# - If a geo first appears halfway through the dataset, it will be
302-
# completed all the way back to the beginning of the data.
303-
tidyr::complete(x,
294+
# Add in rows for each present key column combination for all dates.
295+
# - This happens within each group if the data is grouped. This
296+
# doesn't change the impact of completion because we apply the
297+
# computation by group as well.
298+
# - If a geo first appears halfway through the dataset, it will be
299+
# completed all the way back to the beginning of the data.
300+
x <- tidyr::complete(x,
304301
expand(x, nesting(!!key_cols_no_time), data.frame(time_value = all_dates)),
305302
# `complete` checks that fill types match existing column types.
306303
fill = fill,
307304
# Existing missings will be replaced by `fill`, too.
308305
explicit = TRUE
309306
)
310-
)
307+
308+
# `complete` strips epi_df format and metadata. Restore them.
309+
x <- reclass(x, attributes(x)$metadata)
311310
}
312311

313312
# If a custom time step is specified, then redefine units

0 commit comments

Comments
 (0)