Skip to content

Commit 38a99ee

Browse files
committed
fix: more
1 parent abf0a05 commit 38a99ee

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

R/slide.R

+7-7
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
#' ungroup()
9191
epi_slide <- function(
9292
x, f, ...,
93-
.n = 0, .align = c("right", "center", "left"), .ref_time_values = NULL,
93+
.window_size = 0, .align = c("right", "center", "left"), .ref_time_values = NULL,
9494
.new_col_name = "slide_value", .as_list_col = FALSE, .names_sep = "_", .all_rows = FALSE,
9595
before = NULL, after = NULL, ref_time_values = NULL, new_col_name = NULL,
9696
as_list_col = NULL, names_sep = NULL, all_rows = NULL) {
@@ -130,8 +130,8 @@ epi_slide <- function(
130130
# Handle window arguments
131131
align <- rlang::arg_match(.align)
132132
time_type <- attr(x, "metadata")$time_type
133-
validate_slide_window_arg(.n, time_type)
134-
if (identical(.n, Inf)) {
133+
validate_slide_window_arg(.window_size, time_type)
134+
if (identical(.window_size, Inf)) {
135135
if (align == "right") {
136136
before <- Inf
137137
if (time_type %in% c("day", "week")) {
@@ -146,15 +146,15 @@ epi_slide <- function(
146146
}
147147
} else {
148148
if (align == "right") {
149-
before <- .n - 1
149+
before <- .window_size - 1
150150
after <- 0
151151
} else if (align == "center") {
152152
# For n = 5, before = 2, after = 2. For n = 4, before = 2, after = 1.
153-
before <- floor(.n / 2)
154-
after <- .n - before - 1
153+
before <- floor(.window_size / 2)
154+
after <- .window_size - before - 1
155155
} else if (align == "left") {
156156
before <- 0
157-
after <- .n - 1
157+
after <- .window_size - 1
158158
}
159159
}
160160

man-roxygen/basic-slide-params.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#' @param x The `epi_df` object under consideration, [grouped][dplyr::group_by]
22
#' or ungrouped. If ungrouped, all data in `x` will be treated as part of a
33
#' single data group.
4-
#' @param .n The size of the sliding window. By default, this is 0, meaning that
5-
#' only the current ref_time_value is included. The accepted values here depend
6-
#' on the `time_value` column:
4+
#' @param .window_size The size of the sliding window. By default, this is 0,
5+
#' meaning that only the current ref_time_value is included. The accepted values
6+
#' here depend on the `time_value` column:
77
#'
88
#' - if time_type is Date and the cadence is daily, then `.n` can be an integer
99
#' (which will be interpreted in units of days) or a difftime with units

0 commit comments

Comments
 (0)