Open dsweber2 opened 3 months ago
Couple notes:
epi_slide_mean()
behavior is result_col_names <- paste0("slide_value_", col_names_chr)
which doesn't properly vectorize to a 0-length result in the case of a 0-length col_names_chr
. [without requiring R >= 4.0.1 and specifying recycle0 = TRUE
]epi_slide()
example, (i) we issue a warning that mean
doesn't look like a proper function to be sliding, (ii) mean
generates a bunch of NAs + warnings from calculating the mean across an epi_df
chunk + group key + ref time value, including non-numeric columns of the epi_df
chunk or group key, and (iii) default R behavior collapses all these warnings into a less-noticeable (especially with my editor's coloring settings) "There were 50 or more warnings (use warnings() to see the first 50)".We can add additional validation/defaults for the epi_slide_mean()
case. To stop the epi_slide()
case, we'd probably need to turn that warning into an error.
Ah, I guess I was a bit confused about epi_slide
working after including the column name. The lack of parallel is unfortunate; it would be nice if epi_slide
accepted this sort of arg that switched it to operating on the specific column.
The tidyverse way would be to use across()
. But that may be in the group of things that really delve into dplyr internals and aren't compatible with (simple usage of) the rlang analogues (that might not even back dplyr ops despite sounding that way??), so allowing across()
in epi_slide()
might not be simple.
In #521 I'm just going for
throw an error saying we need to specify a target
in all cases, plus hinting them to use epi_slide_mean
etc. We could reconsider whether we want to do some sort of special behavior when there's only 1 sensible value column, or maybe doing something for every value column if they are all sensible. But I'm just trying to make sure we have a hard & helpful error as a starting point.
epi_slide_mean
fix [0 cols being fed into epi_slide_mean
. The epi_slide
part is "addressed" with an error message.]
When I don't specify a column,
epi_slide
andepi_slide_mean
have pretty different behavior. Example commandepi_slide_mean(before = 6L)
orepi_slide(mean, before = 6L)
.epi_slide_mean
outputs aCan't recycle input of size 0 to size 1
error, whileepi_slide
just returns a ton ofNA
values.Ideally they would either
edit: second
epi_slide_mean
should've been justepi_slide