Skip to content

Commit 2f873ca

Browse files
authored
Merge pull request #332 from cmu-delphi/dev
Update main branch with v0.7.0
2 parents a509f03 + c3ca17b commit 2f873ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4742
-1002
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
^renv$
2+
^renv\.lock$
13
^.*\.Rproj$
24
^\.Rproj\.user$
35
^LICENSE\.md$

.github/workflows/R-CMD-check.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
#
4+
# Created with usethis + edited to run on PRs to dev, use API key.
35
on:
46
push:
57
branches: [main, master]
68
pull_request:
7-
branches: [main, master]
9+
branches: [main, master, dev]
810

911
name: R-CMD-check
1012

@@ -27,3 +29,5 @@ jobs:
2729
needs: check
2830

2931
- uses: r-lib/actions/check-r-package@v2
32+
env:
33+
DELPHI_EPIDATA_KEY: ${{ secrets.SECRET_EPIPROCESS_GHACTIONS_DELPHI_EPIDATA_KEY }}

.github/workflows/pkgdown.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
#
4+
# Created with usethis + edited to run on PRs to dev, use API key.
35
on:
46
push:
57
branches: [main, master]
68
pull_request:
7-
branches: [main, master]
9+
branches: [main, master, dev]
810
release:
911
types: [published]
1012
workflow_dispatch:
@@ -34,6 +36,8 @@ jobs:
3436
needs: website
3537

3638
- name: Build site
39+
env:
40+
DELPHI_EPIDATA_KEY: ${{ secrets.SECRET_EPIPROCESS_GHACTIONS_DELPHI_EPIDATA_KEY }}
3741
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
3842
shell: Rscript {0}
3943

DESCRIPTION

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
Type: Package
22
Package: epiprocess
33
Title: Tools for basic signal processing in epidemiology
4-
Version: 0.5.0.9999
4+
Version: 0.6.0.9999
55
Authors@R: c(
66
person("Jacob", "Bien", role = "ctb"),
77
person("Logan", "Brooks", role = "aut"),
88
person("Rafael", "Catoia", role = "ctb"),
9+
person("Nat", "DeFries", role = "ctb"),
910
person("Daniel", "McDonald", role = "aut"),
1011
person("Rachel", "Lobay", role = "ctb"),
1112
person("Ken", "Mawer", role = "ctb"),
@@ -20,13 +21,15 @@ Description: This package introduces a common data structure for epidemiological
2021
work with revisions to these data sets over time, and offers associated
2122
utilities to perform basic signal processing tasks.
2223
License: MIT + file LICENSE
23-
Imports:
24+
Imports:
25+
cli,
2426
data.table,
25-
dplyr,
27+
dplyr (>= 1.0.0),
2628
fabletools,
2729
feasts,
2830
generics,
2931
genlasso,
32+
lifecycle (>= 1.0.1),
3033
lubridate,
3134
magrittr,
3235
purrr,
@@ -35,18 +38,18 @@ Imports:
3538
slider,
3639
tibble,
3740
tidyr,
38-
tidyselect,
41+
tidyselect (>= 1.2.0),
3942
tsibble,
40-
utils
43+
utils,
44+
vctrs
4145
Suggests:
4246
covidcast,
4347
epidatr,
4448
ggplot2,
4549
knitr,
4650
outbreaks,
4751
rmarkdown,
48-
testthat (>= 3.0.0),
49-
vctrs,
52+
testthat (>= 3.1.5),
5053
waldo (>= 0.3.1),
5154
withr
5255
VignetteBuilder:
@@ -59,7 +62,22 @@ Config/testthat/edition: 3
5962
Encoding: UTF-8
6063
LazyData: true
6164
Roxygen: list(markdown = TRUE)
62-
RoxygenNote: 7.2.1
65+
RoxygenNote: 7.2.3
6366
Depends:
6467
R (>= 2.10)
6568
URL: https://cmu-delphi.github.io/epiprocess/
69+
Collate:
70+
'archive.R'
71+
'correlation.R'
72+
'data.R'
73+
'epi_df.R'
74+
'epiprocess.R'
75+
'methods-epi_archive.R'
76+
'grouped_epi_archive.R'
77+
'growth_rate.R'
78+
'methods-epi_df.R'
79+
'outliers.R'
80+
'reexports.R'
81+
'slide.R'
82+
'utils.R'
83+
'utils_pipe.R'

NAMESPACE

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
# Generated by roxygen2: do not edit by hand
22

33
S3method("[",epi_df)
4-
S3method(arrange,epi_df)
4+
S3method("names<-",epi_df)
55
S3method(as_epi_df,data.frame)
66
S3method(as_epi_df,epi_df)
77
S3method(as_epi_df,tbl_df)
88
S3method(as_epi_df,tbl_ts)
9+
S3method(as_tibble,epi_df)
910
S3method(as_tsibble,epi_df)
10-
S3method(filter,epi_df)
11+
S3method(dplyr_col_modify,col_modify_recorder_df)
12+
S3method(dplyr_col_modify,epi_df)
13+
S3method(dplyr_reconstruct,epi_df)
14+
S3method(dplyr_row_slice,epi_df)
15+
S3method(epix_truncate_versions_after,epi_archive)
16+
S3method(epix_truncate_versions_after,grouped_epi_archive)
17+
S3method(group_by,epi_archive)
1118
S3method(group_by,epi_df)
19+
S3method(group_by,grouped_epi_archive)
20+
S3method(group_by_drop_default,grouped_epi_archive)
1221
S3method(group_modify,epi_df)
13-
S3method(mutate,epi_df)
22+
S3method(groups,grouped_epi_archive)
1423
S3method(next_after,Date)
1524
S3method(next_after,integer)
1625
S3method(print,epi_df)
17-
S3method(relocate,epi_df)
18-
S3method(rename,epi_df)
19-
S3method(slice,epi_df)
2026
S3method(summary,epi_df)
2127
S3method(ungroup,epi_df)
28+
S3method(ungroup,grouped_epi_archive)
2229
S3method(unnest,epi_df)
2330
export("%>%")
2431
export(archive_cases_dv_subset)
@@ -35,12 +42,14 @@ export(epi_slide)
3542
export(epix_as_of)
3643
export(epix_merge)
3744
export(epix_slide)
45+
export(epix_truncate_versions_after)
3846
export(filter)
3947
export(group_by)
4048
export(group_modify)
4149
export(growth_rate)
4250
export(is_epi_archive)
4351
export(is_epi_df)
52+
export(is_grouped_epi_archive)
4453
export(max_version_with_row_in)
4554
export(mutate)
4655
export(new_epi_df)
@@ -60,9 +69,16 @@ importFrom(data.table,key)
6069
importFrom(data.table,set)
6170
importFrom(data.table,setkeyv)
6271
importFrom(dplyr,arrange)
72+
importFrom(dplyr,bind_rows)
73+
importFrom(dplyr,dplyr_col_modify)
74+
importFrom(dplyr,dplyr_reconstruct)
75+
importFrom(dplyr,dplyr_row_slice)
6376
importFrom(dplyr,filter)
6477
importFrom(dplyr,group_by)
78+
importFrom(dplyr,group_by_drop_default)
6579
importFrom(dplyr,group_modify)
80+
importFrom(dplyr,group_vars)
81+
importFrom(dplyr,groups)
6682
importFrom(dplyr,mutate)
6783
importFrom(dplyr,relocate)
6884
importFrom(dplyr,rename)
@@ -72,20 +88,37 @@ importFrom(dplyr,ungroup)
7288
importFrom(lubridate,days)
7389
importFrom(lubridate,weeks)
7490
importFrom(magrittr,"%>%")
91+
importFrom(purrr,map_lgl)
7592
importFrom(rlang,"!!!")
7693
importFrom(rlang,"!!")
7794
importFrom(rlang,.data)
7895
importFrom(rlang,.env)
7996
importFrom(rlang,arg_match)
97+
importFrom(rlang,caller_arg)
98+
importFrom(rlang,caller_env)
99+
importFrom(rlang,check_dots_empty0)
80100
importFrom(rlang,enquo)
81101
importFrom(rlang,enquos)
102+
importFrom(rlang,env)
103+
importFrom(rlang,f_env)
104+
importFrom(rlang,f_rhs)
105+
importFrom(rlang,global_env)
106+
importFrom(rlang,is_environment)
107+
importFrom(rlang,is_formula)
108+
importFrom(rlang,is_function)
109+
importFrom(rlang,is_missing)
82110
importFrom(rlang,is_quosure)
111+
importFrom(rlang,is_string)
112+
importFrom(rlang,missing_arg)
113+
importFrom(rlang,new_function)
83114
importFrom(rlang,quo_is_missing)
84115
importFrom(rlang,sym)
85116
importFrom(rlang,syms)
86117
importFrom(stats,cor)
87118
importFrom(stats,median)
119+
importFrom(tibble,as_tibble)
88120
importFrom(tidyr,unnest)
89121
importFrom(tidyselect,eval_select)
90122
importFrom(tidyselect,starts_with)
91123
importFrom(tsibble,as_tsibble)
124+
importFrom(utils,tail)

NEWS.md

Lines changed: 135 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,144 @@
1-
# epiprocess 0.5.0.9999 (development version)
1+
# epiprocess 0.7.0
22

33
Note that `epiprocess` uses the [Semantic Versioning
4-
("semver")](https://semver.org/) scheme for all release versions, but not for
5-
development versions. A ".9999" suffix indicates a development version.
4+
("semver")](https://semver.org/) scheme for all release versions, but any
5+
inter-release development versions will include an additional ".9999" suffix.
6+
7+
## Breaking changes:
8+
9+
* Changes to `epi_slide` and `epix_slide`:
10+
* If `f` is a function, it is now required to take at least three arguments.
11+
`f` must take an `epi_df` with the same column names as the archive's `DT`,
12+
minus the `version` column; followed by a one-row tibble containing the
13+
values of the grouping variables for the associated group; followed by a
14+
reference time value, usually as a `Date` object. Optionally, it can take
15+
any number of additional arguments after that, and forward values for those
16+
arguments through `epi[x]_slide`'s `...` args.
17+
* To make your existing slide computations work, add a third argument to
18+
your `f` function to accept this new input: e.g., change `f = function(x,
19+
g, <any other arguments>) { <body> }` to `f = function(x, g, rt, <any
20+
other arguments>) { <body> }`.
21+
22+
## New features:
23+
24+
* `epi_slide` and `epix_slide` also make the window data, group key and reference
25+
time value available to slide computations specified as formulas or tidy
26+
evaluation expressions, in additional or completely new ways.
27+
* If `f` is a formula, it can now access the reference time value via `.z` or
28+
`.ref_time_value`.
29+
* If `f` is missing, the tidy evaluation expression in `...` can now refer to
30+
the window data as an `epi_df` or `tibble` with `.x`, the group key with
31+
`.group_key`, and the reference time value with `.ref_time_value`. The usual
32+
`.data` and `.env` pronouns also work, but`pick()` and `cur_data()` are not;
33+
work off of `.x` instead.
34+
* `epix_slide` has been made more like `dplyr::group_modify`. It will no longer
35+
perform element/row recycling for size stability, accepts slide computation
36+
outputs containing any number of rows, and no longer supports `all_rows`.
37+
* To keep the old behavior, manually perform row recycling within `f`
38+
computations, and/or `left_join` a data frame representing the desired
39+
output structure with the current `epix_slide()` result to obtain the
40+
desired repetitions and completions expected with `all_rows = TRUE`.
41+
* `epix_slide` will only output grouped or ungrouped tibbles. Previously, it
42+
would sometimes output `epi_df`s, but not consistently, and not always with
43+
the metadata desired. Future versions will revisit this design, and consider
44+
more closely whether/when/how to output an `epi_df`.
45+
* To keep the old behavior, convert the output of `epix_slide()` to `epi_df`
46+
when desired and set the metadata appropriately.
47+
48+
## Improvements:
49+
50+
* `epi_slide` and `epix_slide` now support `as_list_col = TRUE` when the slide
51+
computations output atomic vectors, and output a list column in "chopped"
52+
format (see `tidyr::chop`).
53+
* `epi_slide` now works properly with slide computations that output just a
54+
`Date` vector, rather than converting `slide_value` to a numeric column.
55+
56+
# epiprocess 0.6.0
57+
58+
## Breaking changes:
59+
60+
* Changes to both `epi_slide` and `epix_slide`:
61+
* The `n`, `align`, and `before` arguments have been replaced by new `before`
62+
and `after` arguments. To migrate to the new version, replace these
63+
arguments in every `epi_slide` and `epix_slide` call. If you were only using
64+
the `n` argument, then this means replacing `n = <n value>` with `before =
65+
<n value> - 1`.
66+
* `epi_slide`'s time windows now extend `before` time steps before and
67+
`after` time steps after the corresponding `ref_time_values`. See
68+
`?epi_slide` for details on matching old alignments.
69+
* `epix_slide`'s time windows now extend `before` time steps before the
70+
corresponding `ref_time_values` all the way through the latest data
71+
available at the corresponding `ref_time_values`.
72+
* Slide functions now keep any grouping of `x` in their results, like
73+
`mutate` and `group_modify`.
74+
* To obtain the old behavior, `dplyr::ungroup` the slide results immediately.
75+
* Additional `epi_slide` changes:
76+
* When using `as_list_col = TRUE` together with `ref_time_values` and
77+
`all_rows=TRUE`, the marker for excluded computations is now a `NULL` entry
78+
in the list column, rather than a `NA`; if you are using `tidyr::unnest()`
79+
afterward and want to keep these missing data markers, you will need to
80+
replace the `NULL` entries with `NA`s. Skipped computations are now more
81+
uniformly detectable using `vctrs` methods.
82+
* Additional`epix_slide` changes:
83+
* `epix_slide`'s `group_by` argument has been replaced by `dplyr::group_by` and
84+
`dplyr::ungroup` S3 methods. The `group_by` method uses "data masking" (also
85+
referred to as "tidy evaluation") rather than "tidy selection".
86+
* Old syntax:
87+
* `x %>% epix_slide(<other args>, group_by=c(col1, col2))`
88+
* `x %>% epix_slide(<other args>, group_by=all_of(colname_vector))`
89+
* New syntax:
90+
* `x %>% group_by(col1, col2) %>% epix_slide(<other args>)`
91+
* `x %>% group_by(across(all_of(colname_vector))) %>% epix_slide(<other args>)`
92+
* `epix_slide` no longer defaults to grouping by non-`time_value`, non-`version`
93+
key columns, instead considering all data to be in one big group.
94+
* To obtain the old behavior, precede each `epix_slide` call lacking a
95+
`group_by` argument with an appropriate `group_by` call.
96+
* `epix_slide` now guesses `ref_time_values` to be a regularly spaced sequence
97+
covering all the `DT$version` values and the `version_end`, rather than the
98+
distinct `DT$time_value`s. To obtain the old behavior, pass in
99+
`ref_time_values = unique(<ungrouped archive>$DT$time_value)`.
100+
* `epi_archive`'s `clobberable_versions_start`'s default is now `NA`, so there
101+
will be no warnings by default about potential nonreproducibility. To obtain
102+
the old behavior, pass in `clobberable_versions_start =
103+
max_version_with_row_in(x)`.
104+
105+
## Potentially-breaking changes:
106+
107+
* Fixed `[` on grouped `epi_df`s to maintain the grouping if possible when
108+
dropping the `epi_df` class (e.g., when removing the `time_value` column).
109+
* Fixed `epi_df` operations to be more consistent about decaying into
110+
non-`epi_df`s when the result of the operation doesn't make sense as an
111+
`epi_df` (e.g., when removing the `time_value` column).
112+
* Changed `bind_rows` on grouped `epi_df`s to not drop the `epi_df` class. Like
113+
with ungrouped `epi_df`s, the metadata of the result is still simply taken
114+
from the first result, and may be inappropriate
115+
([#242](https://github.com/cmu-delphi/epiprocess/issues/242)).
116+
* `epi_slide` and `epix_slide` now raise an error rather than silently filtering
117+
out `ref_time_values` that don't meet their expectations.
118+
119+
## New features:
120+
121+
* `epix_slide`, `<epi_archive>$slide` have a new parameter `all_versions`. With
122+
`all_versions=TRUE`, `epix_slide` will pass a filtered `epi_archive` to each
123+
computation rather than an `epi_df` snapshot. This enables, e.g., performing
124+
pseudoprospective forecasts with a revision-aware forecaster using nested
125+
`epix_slide` operations.
126+
127+
## Improvements:
128+
129+
* Added `dplyr::group_by` and `dplyr::ungroup` S3 methods for `epi_archive`
130+
objects, plus corresponding `$group_by` and `$ungroup` R6 methods. The
131+
`group_by` implementation supports the `.add` and `.drop` arguments, and
132+
`ungroup` supports partial ungrouping with `...`.
133+
* `as_epi_archive`, `epi_archive$new` now perform checks for the key uniqueness
134+
requirement (part of
135+
[#154](https://github.com/cmu-delphi/epiprocess/issues/154)).
6136

7137
## Cleanup:
8138

9139
* Added a `NEWS.md` file to track changes to the package.
140+
* Implemented `?dplyr::dplyr_extending` for `epi_df`s
141+
([#223](https://github.com/cmu-delphi/epiprocess/issues/223)).
10142
* Fixed various small documentation issues ([#217](https://github.com/cmu-delphi/epiprocess/issues/217)).
11143

12144
# epiprocess 0.5.0:

0 commit comments

Comments
 (0)