Skip to content

Replaced n in epi_slide and epix_slide #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 68 commits into from

Conversation

kenmawer
Copy link
Contributor

I had pulled in epi_slide to try to fix a bug, hence it incorporates changes from #188.

kenmawer added 30 commits July 13, 2022 18:09
Merge branch 'main' of https://github.com/cmu-delphi/epiprocess into km-fix-epix_slide

# Conflicts:
#	R/methods-epi_archive.R
#	man/epix_slide.Rd
#	tests/testthat/test-methods-epi_archive.R
@kenmawer
Copy link
Contributor Author

Note: I can do a new one without those changes from #188 if needed. However, both of these are similar to each other.

R/archive.R Outdated
if (missing(ref_time_values)) {
ref_time_values = unique(self$DT$time_value)
if (missing(ref_versions)) {
ref_versions = unique(self$DT$version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on discussion with Ryan, we shouldn't rename ref_time_values (yet, at least).

R/archive.R Outdated
@@ -584,23 +584,24 @@ epi_archive =
#' details.
#' @importFrom data.table key
#' @importFrom rlang !! !!! enquo quo_is_missing enquos is_quosure sym syms
slide = function(f, ..., n, group_by, ref_time_values,
slide = function(f, ..., max_version_gap, group_by,
ref_versions,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on discussion with Ryan, max_version_gap should be called before.

R/archive.R Outdated
@@ -619,7 +620,7 @@ epi_archive =
# Computation for one group, one time value
comp_one_grp = function(.data_group,
f, ...,
time_value,
version,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line with the above, please call this ref_time_value.

R/archive.R Outdated
@@ -665,21 +666,22 @@ epi_archive =

# Note that we've already recycled comp value to make size stable,
# so tibble() will just recycle time value appropriately
return(tibble::tibble(time_value = time_value,
return(tibble::tibble(version = version,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, we've put such changes on hold / are still discussing; this should be time_value = ref_time_value. (#163)

R/archive.R Outdated
if (rlang::is_formula(f)) f = rlang::as_function(f)

x = purrr::map_dfr(ref_time_values, function(t) {
x = purrr::map_dfr(ref_versions, function(t) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename t -> ref_time_value to improve consistency with the current naming approach.

R/archive.R Outdated
@@ -701,13 +703,13 @@ epi_archive =
f = function(x, quo, ...) rlang::eval_tidy(quo, x)
new_col = sym(names(rlang::quos_auto_name(quos)))

x = purrr::map_dfr(ref_time_values, function(t) {
x = purrr::map_dfr(ref_versions, function(t) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

})

test_that("epix_slide works as intended",{
x2 <- ea$clone()$DT %>%
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to construct x2 from scratch in case we change archive_cases_dv_subset, and to make this more readable? (tribble sometimes helps make this easier. Or tribble + unnest, something like tibble::tribble(~v, ~t, 5, 1:4, 6, 1:5) %>% tidyr::unnest(t))

@kenmawer kenmawer closed this Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants