Skip to content

Commit a805c2a

Browse files
authored
Merge pull request #444 from cmu-delphi/440-epiprocess-imports
440 epiprocess imports
2 parents ba0a94f + 3903960 commit a805c2a

Some content is hidden

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

69 files changed

+222
-306
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: epipredict
22
Title: Basic epidemiology forecasting methods
3-
Version: 0.1.10
3+
Version: 0.1.11
44
Authors@R: c(
55
person("Daniel J.", "McDonald", , "[email protected]", role = c("aut", "cre")),
66
person("Ryan", "Tibshirani", , "[email protected]", role = "aut"),
@@ -25,14 +25,14 @@ URL: https://github.com/cmu-delphi/epipredict/,
2525
BugReports: https://github.com/cmu-delphi/epipredict/issues/
2626
Depends:
2727
epidatasets,
28-
epiprocess (>= 0.10.4),
2928
parsnip (>= 1.0.0),
3029
R (>= 3.5.0)
3130
Imports:
3231
checkmate,
3332
cli,
3433
distributional,
3534
dplyr,
35+
epiprocess (>= 0.10.4),
3636
generics,
3737
ggplot2,
3838
glue,

NAMESPACE

+16
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ export(arx_class_epi_workflow)
144144
export(arx_classifier)
145145
export(arx_fcast_epi_workflow)
146146
export(arx_forecaster)
147+
export(as_epi_df)
148+
export(as_tibble)
147149
export(autoplot)
148150
export(bake)
149151
export(cdc_baseline_args_list)
@@ -160,6 +162,7 @@ export(extract_argument)
160162
export(extract_frosting)
161163
export(extract_layers)
162164
export(extrapolate_quantiles)
165+
export(filter)
163166
export(fit)
164167
export(flatline)
165168
export(flatline_args_list)
@@ -171,6 +174,7 @@ export(get_test_data)
171174
export(is_epi_recipe)
172175
export(is_epi_workflow)
173176
export(is_layer)
177+
export(key_colnames)
174178
export(layer)
175179
export(layer_add_forecast_date)
176180
export(layer_add_target_date)
@@ -184,17 +188,22 @@ export(layer_quantile_distn)
184188
export(layer_residual_quantiles)
185189
export(layer_threshold)
186190
export(layer_unnest)
191+
export(mutate)
187192
export(nested_quantiles)
188193
export(new_default_epi_recipe_blueprint)
189194
export(new_epi_recipe_blueprint)
195+
export(pivot_longer)
190196
export(pivot_quantiles_longer)
191197
export(pivot_quantiles_wider)
198+
export(pivot_wider)
192199
export(prep)
193200
export(quantile_reg)
194201
export(rand_id)
195202
export(remove_epi_recipe)
196203
export(remove_frosting)
197204
export(remove_model)
205+
export(rename)
206+
export(select)
198207
export(slather)
199208
export(smooth_quantile_reg)
200209
export(step_adjust_latency)
@@ -208,6 +217,7 @@ export(step_population_scaling)
208217
export(step_training_window)
209218
export(tibble)
210219
export(tidy)
220+
export(unnest)
211221
export(update_epi_recipe)
212222
export(update_frosting)
213223
export(update_model)
@@ -256,8 +266,12 @@ importFrom(dplyr,summarize)
256266
importFrom(dplyr,tibble)
257267
importFrom(dplyr,tribble)
258268
importFrom(dplyr,ungroup)
269+
importFrom(epiprocess,as_epi_df)
259270
importFrom(epiprocess,epi_slide)
260271
importFrom(epiprocess,growth_rate)
272+
importFrom(epiprocess,growth_rate_params)
273+
importFrom(epiprocess,is_epi_df)
274+
importFrom(epiprocess,key_colnames)
261275
importFrom(generics,augment)
262276
importFrom(generics,fit)
263277
importFrom(generics,forecast)
@@ -316,6 +330,8 @@ importFrom(tidyr,crossing)
316330
importFrom(tidyr,drop_na)
317331
importFrom(tidyr,expand_grid)
318332
importFrom(tidyr,fill)
333+
importFrom(tidyr,pivot_longer)
334+
importFrom(tidyr,pivot_wider)
319335
importFrom(tidyr,unnest)
320336
importFrom(tidyselect,all_of)
321337
importFrom(utils,capture.output)

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.0.x will indicat
1414
- Addresses upstream breaking changes from cmu-delphi/epiprocess#595 (`growth_rate()`).
1515
`step_growth_rate()` has lost its `additional_gr_args_list` argument and now
1616
has an `na_rm` argument.
17+
- Moves `epiprocess` out of depends (#440). No internals have changed, but downstream
18+
users may need to add `library(epiprocess)` to existing code.
1719

1820
## Improvements
1921

R/arx_classifier.R

-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#' @seealso [arx_class_epi_workflow()], [arx_class_args_list()]
2727
#'
2828
#' @examples
29-
#' library(dplyr)
3029
#' tiny_geos <- c("as", "mp", "vi", "gu", "pr")
3130
#' jhu <- covid_case_death_rates %>%
3231
#' filter(time_value >= as.Date("2021-11-01"), !(geo_value %in% tiny_geos))
@@ -107,7 +106,6 @@ arx_classifier <- function(
107106
#' @export
108107
#' @seealso [arx_classifier()] [arx_class_args_list()]
109108
#' @examples
110-
#' library(dplyr)
111109
#' jhu <- covid_case_death_rates %>%
112110
#' filter(time_value >= as.Date("2021-11-01"))
113111
#'

R/arx_forecaster.R

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ arx_forecaster <- function(
9595
#' @seealso [arx_forecaster()]
9696
#'
9797
#' @examples
98-
#' library(dplyr)
9998
#' jhu <- covid_case_death_rates %>%
10099
#' filter(time_value >= as.Date("2021-12-01"))
101100
#'

R/autoplot.R

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ ggplot2::autoplot
2828
#'
2929
#' @name autoplot-epipred
3030
#' @examples
31-
#' library(dplyr)
3231
#' jhu <- covid_case_death_rates %>%
3332
#' filter(time_value >= as.Date("2021-11-01"))
3433
#'

R/cdc_baseline_forecaster.R

+19-19
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#'
2424
#' @examples
2525
#' library(dplyr)
26+
#' library(epiprocess)
2627
#' weekly_deaths <- covid_case_death_rates %>%
2728
#' select(geo_value, time_value, death_rate) %>%
2829
#' left_join(state_census %>% select(pop, abbr), by = c("geo_value" = "abbr")) %>%
@@ -36,25 +37,24 @@
3637
#' cdc <- cdc_baseline_forecaster(weekly_deaths, "deaths_7dsum")
3738
#' preds <- pivot_quantiles_wider(cdc$predictions, .pred_distn)
3839
#'
39-
#' if (require(ggplot2)) {
40-
#' forecast_date <- unique(preds$forecast_date)
41-
#' four_states <- c("ca", "pa", "wa", "ny")
42-
#' preds %>%
43-
#' filter(geo_value %in% four_states) %>%
44-
#' ggplot(aes(target_date)) +
45-
#' geom_ribbon(aes(ymin = `0.1`, ymax = `0.9`), fill = blues9[3]) +
46-
#' geom_ribbon(aes(ymin = `0.25`, ymax = `0.75`), fill = blues9[6]) +
47-
#' geom_line(aes(y = .pred), color = "orange") +
48-
#' geom_line(
49-
#' data = weekly_deaths %>% filter(geo_value %in% four_states),
50-
#' aes(x = time_value, y = deaths_7dsum)
51-
#' ) +
52-
#' scale_x_date(limits = c(forecast_date - 90, forecast_date + 30)) +
53-
#' labs(x = "Date", y = "Weekly deaths") +
54-
#' facet_wrap(~geo_value, scales = "free_y") +
55-
#' theme_bw() +
56-
#' geom_vline(xintercept = forecast_date)
57-
#' }
40+
#' library(ggplot2)
41+
#' forecast_date <- unique(preds$forecast_date)
42+
#' four_states <- c("ca", "pa", "wa", "ny")
43+
#' preds %>%
44+
#' filter(geo_value %in% four_states) %>%
45+
#' ggplot(aes(target_date)) +
46+
#' geom_ribbon(aes(ymin = `0.1`, ymax = `0.9`), fill = blues9[3]) +
47+
#' geom_ribbon(aes(ymin = `0.25`, ymax = `0.75`), fill = blues9[6]) +
48+
#' geom_line(aes(y = .pred), color = "orange") +
49+
#' geom_line(
50+
#' data = weekly_deaths %>% filter(geo_value %in% four_states),
51+
#' aes(x = time_value, y = deaths_7dsum)
52+
#' ) +
53+
#' scale_x_date(limits = c(forecast_date - 90, forecast_date + 30)) +
54+
#' labs(x = "Date", y = "Weekly deaths") +
55+
#' facet_wrap(~geo_value, scales = "free_y") +
56+
#' theme_bw() +
57+
#' geom_vline(xintercept = forecast_date)
5858
cdc_baseline_forecaster <- function(
5959
epi_data,
6060
outcome,

R/create-layer.R

-45
This file was deleted.

R/epi_recipe.R

+4-15
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,14 @@ epi_recipe <- function(x, ...) {
4545
#'
4646
#' @export
4747
#' @examples
48-
#' library(dplyr)
49-
#' library(recipes)
5048
#' jhu <- covid_case_death_rates %>%
51-
#' filter(time_value > "2021-08-01") %>%
52-
#' arrange(geo_value, time_value)
49+
#' filter(time_value > "2021-08-01")
5350
#'
5451
#' r <- epi_recipe(jhu) %>%
5552
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
5653
#' step_epi_ahead(death_rate, ahead = 7) %>%
5754
#' step_epi_lag(case_rate, lag = c(0, 7, 14)) %>%
58-
#' step_naomit(all_predictors()) %>%
59-
#' # below, `skip` means we don't do this at predict time
60-
#' step_naomit(all_outcomes(), skip = TRUE)
55+
#' step_epi_naomit()
6156
#'
6257
#' r
6358
epi_recipe.epi_df <- function(x,
@@ -271,19 +266,14 @@ is_epi_recipe <- function(x) {
271266
#'
272267
#' @export
273268
#' @examples
274-
#' library(dplyr)
275-
#' library(recipes)
276-
#'
277269
#' jhu <- covid_case_death_rates %>%
278-
#' filter(time_value > "2021-08-01") %>%
279-
#' arrange(geo_value, time_value)
270+
#' filter(time_value > "2021-08-01")
280271
#'
281272
#' r <- epi_recipe(jhu) %>%
282273
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
283274
#' step_epi_ahead(death_rate, ahead = 7) %>%
284275
#' step_epi_lag(case_rate, lag = c(0, 7, 14)) %>%
285-
#' step_naomit(all_predictors()) %>%
286-
#' step_naomit(all_outcomes(), skip = TRUE)
276+
#' step_epi_naomit()
287277
#'
288278
#' workflow <- epi_workflow() %>%
289279
#' add_epi_recipe(r)
@@ -355,7 +345,6 @@ update_epi_recipe <- function(x, recipe, ..., blueprint = default_epi_recipe_blu
355345
#'
356346
#' @export
357347
#' @examples
358-
#' library(dplyr)
359348
#' library(workflows)
360349
#'
361350
#' jhu <- covid_case_death_rates %>%

R/epipredict-package.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#' @importFrom dplyr full_join relocate summarise everything
1010
#' @importFrom dplyr inner_join
1111
#' @importFrom dplyr summarize filter mutate select left_join rename ungroup
12+
#' @importFrom epiprocess growth_rate growth_rate_params is_epi_df
1213
#' @importFrom magrittr extract2
1314
#' @importFrom rlang := !! %||% as_function global_env set_names !!! caller_arg
1415
#' @importFrom rlang is_logical is_true inject enquo enquos expr sym arg_match
1516
#' @importFrom stats poly predict lm residuals quantile
1617
#' @importFrom tibble as_tibble
17-
na_chr <- NA_character_
1818
## usethis namespace: end
1919
NULL

R/flusight_hub_formatter.R

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ abbr_to_location <- function(abbr) {
5555
#'
5656
#' @examples
5757
#' library(dplyr)
58+
#' library(epiprocess)
5859
#' weekly_deaths <- covid_case_death_rates %>%
5960
#' filter(
6061
#' time_value >= as.Date("2021-09-01"),

R/frosting.R

-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#' @export
99
#'
1010
#' @examples
11-
#' library(dplyr)
1211
#' jhu <- covid_case_death_rates %>%
1312
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
1413
#' r <- epi_recipe(jhu) %>%
@@ -127,7 +126,6 @@ update_frosting <- function(x, frosting, ...) {
127126
#'
128127
#' @export
129128
#' @examples
130-
#' library(dplyr)
131129
#' jhu <- covid_case_death_rates %>%
132130
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
133131
#' r <- epi_recipe(jhu) %>%
@@ -262,7 +260,6 @@ new_frosting <- function() {
262260
#' @export
263261
#'
264262
#' @examples
265-
#' library(dplyr)
266263
#' # Toy example to show that frosting can be created and added for postprocessing
267264
#' f <- frosting()
268265
#' wf <- epi_workflow() %>% add_frosting(f)

R/layer_add_forecast_date.R

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#'
2222
#' @export
2323
#' @examples
24-
#' library(dplyr)
2524
#' jhu <- covid_case_death_rates %>%
2625
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
2726
#' r <- epi_recipe(jhu) %>%

R/layer_add_target_date.R

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#'
2525
#' @export
2626
#' @examples
27-
#' library(dplyr)
2827
#' jhu <- covid_case_death_rates %>%
2928
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
3029
#' r <- epi_recipe(jhu) %>%

0 commit comments

Comments
 (0)