Skip to content

Commit c1a9e10

Browse files
committed
use purrr::reduce instead of base::Reduce
1 parent 678a7e4 commit c1a9e10

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

backfill_corrections/delphiBackfillCorrection/NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ importFrom(lubridate,month)
5050
importFrom(lubridate,year)
5151
importFrom(parallel,detectCores)
5252
importFrom(purrr,map_dfc)
53+
importFrom(purrr,reduce)
5354
importFrom(quantgen,quantile_lasso)
5455
importFrom(readr,write_csv)
5556
importFrom(stats,coef)

backfill_corrections/delphiBackfillCorrection/R/preprocessing.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ add_weekofmonth <- function(df, time_col, wm = WEEK_ISSUES) {
188188
#' @template ref_lag-template
189189
#'
190190
#' @importFrom dplyr full_join left_join
191+
#' @importFrom purrr reduce
191192
#' @importFrom tidyr pivot_wider drop_na
192193
#'
193194
#' @export
@@ -205,10 +206,10 @@ add_7davs_and_target <- function(df, value_col, refd_col, lag_col, ref_lag) {
205206
avg_df_prev7 <- add_shift(avg_df, 7, refd_col)
206207
names(avg_df_prev7)[names(avg_df_prev7) == 'value_7dav'] <- 'value_prev_7dav'
207208

208-
backfill_df <- Reduce(
209-
function(x, y) full_join(x, y, by=c("time_value", "issue_date")),
210-
list(df, avg_df, avg_df_prev7)
211-
)
209+
backfill_df <- reduce(
210+
list(df, avg_df, avg_df_prev7),
211+
full_join, by=c(refd_col, "issue_date")
212+
)
212213

213214
# Add target
214215
target_df <- df[df$lag==ref_lag, c(refd_col, value_col, "issue_date")]

0 commit comments

Comments
 (0)