-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
library(epiprocess)
#> Registered S3 method overwritten by 'tsibble':
#> method from
#> as_tibble.grouped_df dplyr
#>
#> Attaching package: 'epiprocess'
#> The following object is masked from 'package:stats':
#>
#> filter
varname <- "case_rate"
varnames <- c("case_rate", "death_rate")
covid_case_death_rates_extended %>% epi_slide_sum(!!varname, .window_size=7)
#> Error in !varname: invalid argument type
covid_case_death_rates_extended %>% epi_slide_sum(!!varnames, .window_size=7)
#> Error in !varnames: invalid argument type
covid_case_death_rates_extended %>% epi_slide_sum(!!varnames, .window_size=7)
#> Error in !varnames: invalid argument typeCreated on 2024-11-03 with reprex v2.1.1
We probably don't need the if branch here and can probably just use the else branch code in any situation.
if (inherits(quo_get_expr(enquo(.col_names)), "character")) {
pos <- eval_select(dplyr::all_of(.col_names), data = .x, allow_rename = FALSE)
} else {
pos <- eval_select(enquo(.col_names), data = .x, allow_rename = FALSE)
}!!varnamesprobably will work, but I'm not sure if this is intended.!!!may or may not work; it may be more "proper" for it not to work, as it looks like splatting multiple arguments into the function, while our.col_namesis just a single arg slot. (If we look at the similaracrossfunction, it will balk with a confusing message if we attempt to use!!!, because it is actually splatting multiple fn args. But I don't think we have fn arg splatting here so it might actually work in our case.)
Workaround is to use manually use all_of(varname) or all_of(varnames) instead of something with !! or !!!.
Metadata
Metadata
Assignees
Labels
No labels