Skip to content

Commit a3e7ae0

Browse files
committed
Remove unnecessary name+unnest(), explain unpack() usage
1 parent 63e1502 commit a3e7ae0

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

_casestudies/forecast-covid/forecast-covid.Rmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ epi_pred_cv_trailing <- epi_slide(
422422
.ref_time_values = fc_time_values,
423423
.new_col_name = "fc"
424424
) |>
425+
# split tibble-type column `fc` into multiple columns with names prefixed by `fc_`:
425426
unpack(fc, names_sep = "_")
426427
427428
# they match exactly

slides/day1-afternoon.qmd

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,10 +2035,8 @@ nowcast_res <- archive |>
20352035
epix_slide(
20362036
.f = lm_mod_pred,
20372037
.before = 14, # 14-day training period
2038-
.versions = ref_time_values,
2039-
.new_col_name = "res"
2038+
.versions = ref_time_values
20402039
) |>
2041-
unnest() |> # Nesting creates a list-column of data frames; unnesting flattens it back out into regular columns.
20422040
mutate(targeted_nowcast_date = targeted_nowcast_dates, time_value = actual_nowcast_date) |>
20432041
ungroup()
20442042
@@ -2425,10 +2423,8 @@ nowcast_res <- archive |>
24252423
epix_slide(
24262424
.f = lm_mod_pred, # Pass the function defined above
24272425
.before = 30, # Training period of 30 days
2428-
.versions = ref_time_values, # Determines the day where training data goes up to (not inclusive)
2429-
.new_col_name = "res"
2426+
.versions = ref_time_values # Determines the day where training data goes up to (not inclusive)
24302427
) |>
2431-
unnest() |>
24322428
mutate(targeted_nowcast_date = targeted_nowcast_dates,
24332429
time_value = actual_nowcast_date)
24342430
@@ -2583,4 +2579,4 @@ cowplot::plot_grid(p1, p2)
25832579

25842580
* Group built [`{rtestim}`](https://dajmcdon.github.io/rtestim) doing for this nonparametrically.
25852581

2586-
* We may come back to this later...
2582+
* We may come back to this later...

0 commit comments

Comments
 (0)