Skip to content

Commit 5ce988b

Browse files
committed
doc: update vignettes
1 parent c73b6c2 commit 5ce988b

23 files changed

+507
-696
lines changed

.Rbuildignore

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@
1616
^.lintr$
1717
^DEVELOPMENT.md$
1818
man-roxygen
19+
^.venv$
20+
^sandbox.R$

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ docs
1313
renv/
1414
renv.lock
1515
.Rprofile
16+
sandbox.R

DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ Imports:
5050
tidyselect (>= 1.2.0),
5151
tsibble,
5252
utils,
53-
vctrs
53+
vctrs,
54+
waldo
5455
Suggests:
5556
covidcast,
5657
devtools,

R/methods-epi_archive.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ epix_detailed_restricted_mutate <- function(.data, ...) {
731731
#' library(dplyr)
732732
#'
733733
#' # Reference time points for which we want to compute slide values:
734-
#' versions <- seq(as.Date("2020-06-01"),
734+
#' versions <- seq(as.Date("2020-06-02"),
735735
#' as.Date("2020-06-15"),
736736
#' by = "1 day"
737737
#' )
@@ -780,7 +780,7 @@ epix_detailed_restricted_mutate <- function(.data, ...) {
780780
#' .versions = versions
781781
#' ) %>%
782782
#' ungroup() %>%
783-
#' arrange(geo_value, time_value)
783+
#' arrange(geo_value, version)
784784
#'
785785
#' # --- Advanced: ---
786786
#'

R/methods-epi_df.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ arrange_col_canonical.epi_df <- function(x, ...) {
427427
x %>% dplyr::relocate(dplyr::all_of(cols), .before = 1)
428428
}
429429

430+
#' Group an `epi_df` object by default keys
431+
#' @param x an `epi_df`
432+
#' @param exclude character vector of column names to exclude from grouping
433+
#' @return a grouped `epi_df`
430434
#' @export
431435
group_epi_df <- function(x, exclude = character()) {
432436
cols <- key_colnames(x, exclude = exclude)
@@ -440,7 +444,7 @@ group_epi_df <- function(x, exclude = character()) {
440444
#' the resulting `epi_df` will have `geo_value` set to `"total"`.
441445
#'
442446
#' @param .x an `epi_df`
443-
#' @param value_col character vector of the columns to aggregate
447+
#' @param sum_cols character vector of the columns to aggregate
444448
#' @param group_cols character vector of column names to group by. "time_value" is
445449
#' included by default.
446450
#' @return an `epi_df` object

R/outliers.R

+5-7
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ detect_outlr <- function(x = seq_along(y), y,
161161
#' group_by(geo_value) %>%
162162
#' mutate(outlier_info = detect_outlr_rm(
163163
#' x = time_value, y = cases
164-
#' )) %>%
165-
#' unnest(outlier_info)
164+
#' ))
166165
detect_outlr_rm <- function(x = seq_along(y), y, n = 21,
167166
log_transform = FALSE,
168167
detect_negatives = FALSE,
@@ -189,7 +188,7 @@ detect_outlr_rm <- function(x = seq_along(y), y, n = 21,
189188

190189
# Calculate lower and upper thresholds and replacement value
191190
z <- z %>%
192-
epi_slide(fitted = median(y), .window_size = n, .align = "center") %>%
191+
epi_slide(fitted = median(y, na.rm = TRUE), .window_size = n, .align = "center") %>%
193192
dplyr::mutate(resid = y - fitted) %>%
194193
roll_iqr(
195194
n = n,
@@ -256,9 +255,8 @@ detect_outlr_rm <- function(x = seq_along(y), y, n = 21,
256255
#' group_by(geo_value) %>%
257256
#' mutate(outlier_info = detect_outlr_stl(
258257
#' x = time_value, y = cases,
259-
#' seasonal_period = 7
260-
#' )) %>% # weekly seasonality for daily data
261-
#' unnest(outlier_info)
258+
#' seasonal_period = 7 # weekly seasonality for daily data
259+
#' ))
262260
detect_outlr_stl <- function(x = seq_along(y), y,
263261
n_trend = 21,
264262
n_seasonal = 21,
@@ -359,7 +357,7 @@ roll_iqr <- function(z, n, detection_multiplier, min_radius,
359357

360358
z %>%
361359
epi_slide(
362-
roll_iqr = stats::IQR(resid),
360+
roll_iqr = stats::IQR(resid, na.rm = TRUE),
363361
.window_size = n, .align = "center"
364362
) %>%
365363
dplyr::mutate(

R/revision_analysis.R

+4-6
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ revision_summary <- function(epi_arch,
8181
should_compactify = TRUE) {
8282
arg <- names(eval_select(rlang::expr(c(...)), allow_rename = FALSE, data = epi_arch$DT))
8383
if (length(arg) == 0) {
84-
first_non_key <- !(names(epi_arch$DT) %in% c(key_colnames(epi_arch), "version"))
85-
arg <- names(epi_arch$DT)[first_non_key][1]
84+
# Choose the first column that's not a key or version
85+
arg <- setdiff(names(epi_arch$DT), c(key_colnames(epi_arch), "version"))[[1]]
8686
} else if (length(arg) > 1) {
8787
cli_abort("Not currently implementing more than one column at a time. Run each separately")
8888
}
@@ -99,11 +99,9 @@ revision_summary <- function(epi_arch,
9999
#
100100
# revision_tibble
101101
keys <- key_colnames(epi_arch)
102-
names(epi_arch$DT)
103102

104-
revision_behavior <-
105-
epi_arch$DT %>%
106-
select(c(geo_value, time_value, all_of(keys), version, !!arg))
103+
revision_behavior <- epi_arch$DT %>%
104+
select(all_of(unique(c("geo_value", "time_value", keys, "version", arg))))
107105
if (!is.null(min_waiting_period)) {
108106
revision_behavior <- revision_behavior %>%
109107
filter(abs(time_value - as.Date(epi_arch$versions_end)) >= min_waiting_period)

R/slide.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ epi_slide_opt <- function(
728728
# positions of user-provided `col_names` into string column names. We avoid
729729
# using `names(pos)` directly for robustness and in case we later want to
730730
# allow users to rename fields via tidyselection.
731-
if (class(quo_get_expr(enquo(.col_names))) == "character") {
731+
if (inherits(quo_get_expr(enquo(.col_names)), "character")) {
732732
pos <- eval_select(dplyr::all_of(.col_names), data = .x, allow_rename = FALSE)
733733
} else {
734734
pos <- eval_select(enquo(.col_names), data = .x, allow_rename = FALSE)

_pkgdown.yml

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ articles:
4848
- aggregation
4949
- outliers
5050
- archive
51-
- advanced
5251
- compactify
5352

5453
repo:

man-roxygen/basic-slide-details.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#' boundary of the dataset) and will attempt to perform the computation
1010
#' anyway. The issue of what to do with partial computations (those run on
1111
#' incomplete windows) is therefore left up to the user, either through the
12-
#' specified function or formula `f`, or through post-processing.
12+
#' specified function or formula, or through post-processing.
1313
#'
1414
#' Let's look at some window examples, assuming that the reference time value
1515
#' is "tv". With .align = "right" and .window_size = 3, the window will be:

man/detect_outlr_rm.Rd

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/detect_outlr_stl.Rd

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/epi_slide.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/epix_slide.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/group_epi_df.Rd

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/sum_groups_epi_df.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)