Skip to content

Refactor epi_slide{,_opt,_mean,_sum}() examples to select() signals at before slide rather than after #455

@brookslogan

Description

@brookslogan

We have several examples like the following

jhu_csse_daily_subset %>%
  group_by(geo_value) %>%
  epi_slide(cases_14dav = mean(cases), before = 6, after = 7) %>%
  # Remove a nonessential var. to ensure new col is printed
  dplyr::select(geo_value, time_value, cases, cases_14dav) %>%
  ungroup()

That comment's a bit obtrusive and annoying. (If it's unclear: this error is explaining why dplyr::select() call exists: to prevent the new columns we just created from being relegated to 1 more variable etc. and not having their actual values displayed by print.epi_df()/print.tibble() in some configurations (it doesn't happen in my R session but it may happen for pkgdown or other people's systems).)

We can probably remove that comment, plus restructure things to help people understand what columns exist in the data set, by using something like

jhu_csse_daily_subset %>%
  dplyr::select(geo_value, time_value, cases) %>%
  group_by(geo_value) %>%
  epi_slide(cases_14dav = mean(cases), before = 6, after = 7) %>%
  ungroup()

instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions