Skip to content

Commit 0e09c4a

Browse files
authored
Merge pull request #579 from cmu-delphi/dev
Release 0.10
2 parents a34bc4b + e5ec121 commit 0e09c4a

36 files changed

+1151
-757
lines changed

.github/workflows/pkgdown.yaml

+6-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
2929
DELPHI_EPIDATA_KEY: ${{ secrets.SECRET_EPIPROCESS_GHACTIONS_DELPHI_EPIDATA_KEY }}
3030
steps:
31-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@v4
3232

3333
- uses: r-lib/actions/setup-pandoc@v2
3434

@@ -42,19 +42,14 @@ jobs:
4242
needs: website
4343

4444
- name: Build site
45-
# - target_ref gets the ref from a different variable, depending on the event
46-
# - override allows us to set the pkgdown mode and version_label
47-
# - mode: release is the standard build mode, devel places the site in /dev
48-
# - version_label: 'light' and 'success' are CSS labels for Bootswatch: Cosmo
49-
# https://bootswatch.com/cosmo/
50-
# - we use pkgdown:::build_github_pages to build the site because of an issue in pkgdown
51-
# https://github.com/r-lib/pkgdown/issues/2257
45+
# our versioning system+dev branch doesn't match the requirements for
46+
# develop mode = auto
5247
run: |
5348
target_ref <- "${{ github.event_name == 'pull_request' && github.base_ref || github.ref }}"
5449
override <- if (target_ref == "main" || target_ref == "refs/heads/main") {
55-
list(development = list(mode = "release", version_label = "light"))
50+
list(development = list(mode = "release"))
5651
} else if (target_ref == "dev" || target_ref == "refs/heads/dev") {
57-
list(development = list(mode = "devel", version_label = "success"))
52+
list(development = list(mode = "devel"))
5853
} else {
5954
stop("Unexpected target_ref: ", target_ref)
6055
}
@@ -67,7 +62,7 @@ jobs:
6762

6863
- name: Deploy to GitHub pages 🚀
6964
if: github.event_name != 'pull_request'
70-
uses: JamesIves/github-pages-deploy-action@v4.4.1
65+
uses: JamesIves/github-pages-deploy-action@v4.5.0
7166
with:
7267
clean: false
7368
branch: gh-pages

DESCRIPTION

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Package: epiprocess
22
Type: Package
33
Title: Tools for basic signal processing in epidemiology
4-
Version: 0.9.6
4+
Version: 0.10.0
55
Authors@R: c(
66
person("Jacob", "Bien", role = "ctb"),
7-
person("Logan", "Brooks", , "[email protected]", role = c("aut", "cre")),
7+
person("Logan", "Brooks", , "lcbrooks+github@andrew.cmu.edu", role = c("aut", "cre")),
88
person("Rafael", "Catoia", role = "ctb"),
99
person("Nat", "DeFries", role = "ctb"),
1010
person("Daniel", "McDonald", role = "aut"),
@@ -13,8 +13,9 @@ Authors@R: c(
1313
person("Chloe", "You", role = "ctb"),
1414
person("Quang", "Nguyen", role = "ctb"),
1515
person("Evan", "Ray", role = "aut"),
16-
person("Dmitry", "Shemetov", role = "ctb"),
16+
person("Dmitry", "Shemetov", role = "aut"),
1717
person("Ryan", "Tibshirani", role = "aut"),
18+
person("David", "Weber", , "[email protected]", role = "ctb"),
1819
person("Lionel", "Henry", role = "ctb",
1920
comment = "Author of included rlang fragments"),
2021
person("Hadley", "Wickham", role = "ctb",
@@ -72,10 +73,12 @@ Suggests:
7273
VignetteBuilder:
7374
knitr
7475
Remotes:
76+
cmu-delphi/delphidocs,
7577
cmu-delphi/epidatasets,
7678
cmu-delphi/epidatr,
7779
glmgen/genlasso,
7880
reconverse/outbreaks
81+
Config/Needs/website: cmu-delphi/delphidocs
7982
Config/testthat/edition: 3
8083
Config/testthat/parallel: true
8184
Copyright: file inst/COPYRIGHTS

NAMESPACE

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ S3method(arrange_row_canonical,default)
1111
S3method(arrange_row_canonical,epi_df)
1212
S3method(as_epi_df,data.frame)
1313
S3method(as_epi_df,epi_df)
14+
S3method(as_epi_df,grouped_df)
1415
S3method(as_epi_df,tbl_df)
1516
S3method(as_epi_df,tbl_ts)
1617
S3method(as_tibble,epi_df)
@@ -108,12 +109,16 @@ importFrom(checkmate,assert)
108109
importFrom(checkmate,assert_character)
109110
importFrom(checkmate,assert_class)
110111
importFrom(checkmate,assert_data_frame)
112+
importFrom(checkmate,assert_false)
111113
importFrom(checkmate,assert_function)
112114
importFrom(checkmate,assert_int)
113115
importFrom(checkmate,assert_list)
114116
importFrom(checkmate,assert_logical)
115117
importFrom(checkmate,assert_numeric)
116118
importFrom(checkmate,assert_scalar)
119+
importFrom(checkmate,assert_string)
120+
importFrom(checkmate,assert_subset)
121+
importFrom(checkmate,assert_tibble)
117122
importFrom(checkmate,checkInt)
118123
importFrom(checkmate,check_atomic)
119124
importFrom(checkmate,check_data_frame)
@@ -163,6 +168,7 @@ importFrom(dplyr,groups)
163168
importFrom(dplyr,if_all)
164169
importFrom(dplyr,if_any)
165170
importFrom(dplyr,if_else)
171+
importFrom(dplyr,is_grouped_df)
166172
importFrom(dplyr,lag)
167173
importFrom(dplyr,mutate)
168174
importFrom(dplyr,near)
@@ -176,6 +182,7 @@ importFrom(dplyr,summarize)
176182
importFrom(dplyr,tibble)
177183
importFrom(dplyr,ungroup)
178184
importFrom(ggplot2,autoplot)
185+
importFrom(glue,glue)
179186
importFrom(lifecycle,deprecated)
180187
importFrom(lubridate,as.period)
181188
importFrom(lubridate,days)
@@ -189,7 +196,6 @@ importFrom(rlang,"%||%")
189196
importFrom(rlang,.data)
190197
importFrom(rlang,.env)
191198
importFrom(rlang,arg_match)
192-
importFrom(rlang,as_label)
193199
importFrom(rlang,caller_arg)
194200
importFrom(rlang,caller_env)
195201
importFrom(rlang,check_dots_empty)
@@ -199,6 +205,7 @@ importFrom(rlang,env)
199205
importFrom(rlang,expr_label)
200206
importFrom(rlang,f_env)
201207
importFrom(rlang,f_rhs)
208+
importFrom(rlang,is_bare_integerish)
202209
importFrom(rlang,is_environment)
203210
importFrom(rlang,is_formula)
204211
importFrom(rlang,is_function)
@@ -207,7 +214,7 @@ importFrom(rlang,is_quosure)
207214
importFrom(rlang,list2)
208215
importFrom(rlang,missing_arg)
209216
importFrom(rlang,new_function)
210-
importFrom(rlang,quo_get_expr)
217+
importFrom(rlang,quo_get_env)
211218
importFrom(rlang,quo_is_missing)
212219
importFrom(rlang,sym)
213220
importFrom(rlang,syms)
@@ -232,3 +239,5 @@ importFrom(tidyselect,starts_with)
232239
importFrom(tsibble,as_tsibble)
233240
importFrom(utils,capture.output)
234241
importFrom(utils,tail)
242+
importFrom(vctrs,vec_data)
243+
importFrom(vctrs,vec_equal)

NEWS.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.x.y will indicat
1414
with `covid`. The data set previously named `jhu_confirmed_cumulative_num` has
1515
been removed from the package, but a renamed version is has been removed from
1616
the package, but a renamed version is still available in `epidatasets`.
17-
18-
## Bug fixes
19-
20-
- Removed `.window_size = 1` default from `epi_slide_{mean,sum,opt}`; this
21-
argument is now mandatory, and should nearly always be greater than 1 except
22-
for testing purposes.
17+
- `epi_slide_{sum,mean,opt}` have improved default output column names, and
18+
additional arguments for specifying names: `.prefix`, `.suffix`,
19+
`.new_col_names`. To obtain the old naming behavior, use `.prefix =
20+
"slide_value_"`.
21+
- `as_epi_df` now removes any grouping that `x` had applied.
2322

2423
## Improvements
2524

@@ -29,6 +28,19 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.x.y will indicat
2928
- Improved validation of `.window_size` arguments.
3029
- Rewrote a lot of the package documentation to be more consistent and
3130
informative. Simplified and streamlined the vignettes.
31+
- `epi_slide_{sum,mean,opt}` on ungrouped `epi_df`s will now temporarily group
32+
by `geo_value` and any `other_keys` for the slide operation rather than raise
33+
an error about duplicated time values. `epi_slide`'s analogous automatic
34+
grouping has been made temporary in order to match.
35+
- Improved speed of key-uniqueness checks.
36+
37+
## Bug fixes
38+
39+
- Removed `.window_size = 1` default from `epi_slide_{mean,sum,opt}`; this
40+
argument is now mandatory, and should nearly always be greater than 1 except
41+
for testing purposes.
42+
- Fixed `epi_slide_{sum,mean,opt}` raising an error on certain tidyselect
43+
expressions.
3244

3345
## Cleanup
3446

R/epi_df.R

+24-14
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ NULL
174174
#' @param other_keys If your tibble has additional keys, be sure to specify them
175175
#' as a character vector here (typical examples are "age" or sub-geographies).
176176
#' @param ... Additional arguments passed to methods.
177-
#' @return An `epi_df` object.
177+
#' @return * Of `new_epi_df()`: an `epi_df`
178178
#'
179179
#' @export
180180
new_epi_df <- function(x = tibble::tibble(geo_value = character(), time_value = as.Date(integer())),
@@ -205,6 +205,8 @@ new_epi_df <- function(x = tibble::tibble(geo_value = character(), time_value =
205205
#' to be converted
206206
#' @param ... used for specifying column names, as in [`dplyr::rename`]. For
207207
#' example, `geo_value = STATEFP, time_value = end_date`.
208+
#' @return * Of `as_epi_df()`: an (ungrouped) `epi_df`
209+
#'
208210
#' @export
209211
as_epi_df <- function(x, ...) {
210212
UseMethod("as_epi_df")
@@ -215,6 +217,7 @@ as_epi_df <- function(x, ...) {
215217
#' @method as_epi_df epi_df
216218
#' @export
217219
as_epi_df.epi_df <- function(x, ...) {
220+
x <- ungroup(x)
218221
return(x)
219222
}
220223

@@ -232,7 +235,6 @@ as_epi_df.tbl_df <- function(
232235
as_of,
233236
other_keys = character(),
234237
...) {
235-
# possible standard substitutions for time_value
236238
x <- rename(x, ...)
237239
x <- guess_column_name(x, "time_value", time_column_names())
238240
x <- guess_column_name(x, "geo_value", geo_column_names())
@@ -277,26 +279,32 @@ as_epi_df.tbl_df <- function(
277279
}
278280

279281
assert_character(other_keys)
282+
assert_subset(other_keys, names(x))
283+
# Fix up if given more than just other keys, at least until epipredict#428
284+
# merged:
285+
other_keys <- other_keys[!other_keys %in% c("geo_value", "time_value")]
280286

281287
if (".time_value_counts" %in% other_keys) {
282288
cli_abort("as_epi_df: `other_keys` can't include \".time_value_counts\"")
283289
}
284290

285-
duplicated_time_values <- x %>%
286-
group_by(across(all_of(c("geo_value", "time_value", other_keys)))) %>%
287-
filter(dplyr::n() > 1) %>%
288-
ungroup()
289-
if (nrow(duplicated_time_values) > 0) {
290-
bad_data <- capture.output(duplicated_time_values)
291-
cli_abort(
292-
"as_epi_df: some groups in the data have duplicated time values. epi_df requires a unique time_value per group.",
293-
body = c("Sample groups:", bad_data)
294-
)
295-
}
291+
assert(check_ukey_unique(x, c("geo_value", other_keys, "time_value"), c(
292+
">" = "If this is line list data, convert it to counts/rates first.",
293+
">" = "If this contains a demographic breakdown, check that you have
294+
specified appropriate `other_keys`" # . from checkmate
295+
)))
296296

297297
new_epi_df(x, geo_type, time_type, as_of, other_keys)
298298
}
299299

300+
#' @rdname epi_df
301+
#' @order 1
302+
#' @method as_epi_df grouped_df
303+
#' @export
304+
as_epi_df.grouped_df <- function(x, ...) {
305+
as_epi_df(ungroup(x), ...)
306+
}
307+
300308
#' @rdname epi_df
301309
#' @order 1
302310
#' @method as_epi_df data.frame
@@ -320,9 +328,11 @@ as_epi_df.tbl_ts <- function(x, as_of, other_keys = character(), ...) {
320328
#' Test for `epi_df` format
321329
#'
322330
#' @param x An object.
323-
#' @return `TRUE` if the object inherits from `epi_df`.
331+
#' @return * Of `is_epi_df`: `TRUE` if the object inherits from `epi_df`,
332+
#' otherwise `FALSE`.
324333
#'
325334
#' @rdname epi_df
335+
#' @order 1
326336
#' @export
327337
is_epi_df <- function(x) {
328338
inherits(x, "epi_df")

R/epiprocess-package.R

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,26 @@
55
#' @import epidatasets
66
#' @importFrom checkmate anyInfinite anyMissing assert assert_character
77
#' @importFrom checkmate assert_class assert_data_frame assert_int assert_list
8+
#' @importFrom checkmate assert_false
89
#' @importFrom checkmate assert_logical assert_numeric assert_scalar checkInt
10+
#' @importFrom checkmate assert_string
11+
#' @importFrom checkmate assert_subset
12+
#' @importFrom checkmate assert_tibble
913
#' @importFrom checkmate check_atomic check_data_frame expect_class test_int
1014
#' @importFrom checkmate check_names
1115
#' @importFrom checkmate test_subset test_set_equal vname
1216
#' @importFrom cli cli_abort cli_warn
1317
#' @importFrom data.table as.data.table
1418
#' @importFrom data.table key
1519
#' @importFrom data.table setkeyv
20+
#' @importFrom dplyr arrange
21+
#' @importFrom dplyr is_grouped_df
1622
#' @importFrom dplyr select
1723
#' @importFrom lifecycle deprecated
1824
#' @importFrom rlang %||%
25+
#' @importFrom rlang is_bare_integerish
26+
#' @importFrom vctrs vec_data
27+
#' @importFrom vctrs vec_equal
1928
## usethis namespace: end
2029
NULL
2130

@@ -24,5 +33,5 @@ utils::globalVariables(c(
2433
"fitted", ".response", "geo_value", "time_value",
2534
"value", ".real", "lag", "max_value", "min_value",
2635
"median_value", "spread", "rel_spread", "time_to",
27-
"time_near_latest", "n_revisions"
36+
"time_near_latest", "n_revisions", "min_lag", "max_lag"
2837
))

R/methods-epi_archive.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -688,10 +688,10 @@ epix_detailed_restricted_mutate <- function(.data, ...) {
688688
#' requested `.versions`) for rows having a `time_value` of at least `.version
689689
#' - before`. Otherwise, the slide computation will be passed only the most
690690
#' recent `version` for every unique `time_value`. Default is `FALSE`.
691-
#' @return A tibble whose columns are: the grouping variables, `time_value`,
692-
#' containing the reference time values for the slide computation, and a
693-
#' column named according to the `.new_col_name` argument, containing the slide
694-
#' values.
691+
#' @return A tibble whose columns are: the grouping variables (if any),
692+
#' `time_value`, containing the reference time values for the slide
693+
#' computation, and a column named according to the `.new_col_name` argument,
694+
#' containing the slide values. It will be grouped by the grouping variables.
695695
#'
696696
#' @details A few key distinctions between the current function and `epi_slide()`:
697697
#' 1. In `.f` functions for `epix_slide`, one should not assume that the input

R/methods-epi_df.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ group_modify.epi_df <- function(.data, .f, ..., .keep = FALSE) {
256256
dplyr::dplyr_reconstruct(NextMethod(), .data)
257257
}
258258

259-
#' Complete epi_df
259+
#' "Complete" an `epi_df`, adding missing rows and/or replacing `NA`s
260260
#'
261-
#' A `tidyr::complete()` analogue for `epi_df`` objects. This function
261+
#' A `tidyr::complete()` analogue for `epi_df` objects. This function
262262
#' can be used, for example, to add rows for missing combinations
263263
#' of `geo_value` and `time_value`, filling other columns with `NA`s.
264264
#' See the examples for usage details.

0 commit comments

Comments
 (0)