Skip to content

wip: rework slide window args #513

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

Merged
merged 11 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Imports:
data.table,
dplyr (>= 1.0.8),
genlasso,
glue,
ggplot2,
glue,
lifecycle (>= 1.0.1),
Expand Down
4 changes: 2 additions & 2 deletions R/autoplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ autoplot.epi_df <- function(
.facet_by = c(".response", "other_keys", "all_keys", "geo_value", "all", "none"),
.base_color = "#3A448F",
.max_facets = Inf) {
.color_by <- match.arg(.color_by)
.facet_by <- match.arg(.facet_by)
.color_by <- rlang::arg_match(.color_by)
.facet_by <- rlang::arg_match(.facet_by)

assert(anyInfinite(.max_facets), checkInt(.max_facets), combine = "or")
assert_character(.base_color, len = 1)
Expand Down
2 changes: 1 addition & 1 deletion R/correlation.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ epi_cor <- function(x, var1, var2, dt1 = 0, dt2 = 0, shift_by = geo_value, # nol
shift_by <- syms(names(eval_select(enquo(shift_by), x)))

# Which method?
method <- match.arg(method)
method <- rlang::arg_match(method)

# Perform time shifts, then compute appropriate correlations and return
return(x %>%
Expand Down
2 changes: 1 addition & 1 deletion R/growth_rate.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ growth_rate <- function(x = seq_along(y), y, x0 = x,
# Check x, y, x0
if (length(x) != length(y)) cli_abort("`x` and `y` must have the same length.")
if (!all(x0 %in% x)) cli_abort("`x0` must be a subset of `x`.")
method <- match.arg(method)
method <- rlang::arg_match(method)

# Arrange in increasing order of x
o <- order(x)
Expand Down
7 changes: 3 additions & 4 deletions R/outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ detect_outlr <- function(x = seq_along(y), y,
),
combiner = c("median", "mean", "none")) {
# Validate combiner
combiner <- match.arg(combiner)
combiner <- rlang::arg_match(combiner)

# Validate that x contains all distinct values
if (any(duplicated(x))) {
Expand Down Expand Up @@ -189,7 +189,7 @@ detect_outlr_rm <- function(x = seq_along(y), y, n = 21,

# Calculate lower and upper thresholds and replacement value
z <- z %>%
epi_slide(fitted = median(y), before = floor((n - 1) / 2), after = ceiling((n - 1) / 2)) %>%
epi_slide(fitted = median(y), .window_size = n, .align = "center") %>%
dplyr::mutate(resid = y - fitted) %>%
roll_iqr(
n = n,
Expand Down Expand Up @@ -360,8 +360,7 @@ roll_iqr <- function(z, n, detection_multiplier, min_radius,
z %>%
epi_slide(
roll_iqr = stats::IQR(resid),
before = floor((n - 1) / 2),
after = ceiling((n - 1) / 2)
.window_size = n, .align = "center"
) %>%
dplyr::mutate(
lower = pmax(
Expand Down
Loading
Loading