Skip to content

Commit 9e93bb8

Browse files
committed
adjust some vignette libraries
1 parent 58980f4 commit 9e93bb8

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

vignettes/backtesting.Rmd

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ vignette: >
1111
source("_common.R")
1212
```
1313

14-
```{r pkgs, include=FALSE, echo=TRUE}
14+
```{r pkgs, message=FALSE}
1515
library(epipredict)
16+
library(epiprocess)
1617
library(epidatr)
1718
library(data.table)
1819
library(dplyr)
@@ -66,7 +67,7 @@ vignette mentioned above).
6667
# Select the `percent_cli` column from the data archive
6768
doctor_visits <- archive_cases_dv_subset$DT %>%
6869
select(geo_value, time_value, version, percent_cli) %>%
69-
tidyr::drop_na(percent_cli) %>%
70+
drop_na(percent_cli) %>%
7071
as_epi_archive(compactify = TRUE)
7172
```
7273

@@ -166,7 +167,7 @@ forecasts %>%
166167
doctor_visits %>%
167168
epix_as_of(doctor_visits$versions_end) %>%
168169
group_by(geo_value) %>%
169-
tidyr::fill(percent_cli),
170+
fill(percent_cli),
170171
by = c("geo_value", "target_date" = "time_value")
171172
) %>%
172173
select(geo_value, forecast_date, .pred, `0.05`, `0.95`, percent_cli)
@@ -376,7 +377,7 @@ linear regression with those from using boosted regression trees.
376377

377378
```{r get-can-fc, warning = FALSE}
378379
aheads <- c(7, 14, 21, 28)
379-
canada_archive <- epidatasets::can_prov_cases
380+
canada_archive <- can_prov_cases
380381
canada_archive_faux <- epix_as_of(canada_archive, canada_archive$versions_end) %>%
381382
mutate(version = time_value) %>%
382383
as_epi_archive()

vignettes/update.Rmd

+11-8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ source("_common.R")
1414
```{r setup, message=FALSE}
1515
library(epipredict)
1616
library(recipes)
17+
library(dplyr)
18+
library(workflows)
19+
library(parsnip)
1720
```
1821

1922
In this vignette, we will state the main goal of the add/update/remove and
@@ -68,7 +71,7 @@ South Carolina.
6871

6972
```{r}
7073
jhu <- covid_case_death_rates %>%
71-
dplyr::filter(time_value >= as.Date("2021-11-01"), geo_value %in% c("ak", "ca", "ny", "sc"))
74+
filter(time_value >= as.Date("2021-11-01"), geo_value %in% c("ak", "ca", "ny", "sc"))
7275
7376
jhu
7477
```
@@ -100,7 +103,7 @@ We may then go on to add the fitted linear model to our `epi_workflow`:
100103

101104
```{r}
102105
# Fit a linear model
103-
wf <- epi_workflow(r, parsnip::linear_reg()) %>% fit(jhu)
106+
wf <- epi_workflow(r, linear_reg()) %>% fit(jhu)
104107
105108
wf
106109
```
@@ -139,7 +142,7 @@ using `workflows::remove_recipe()` and then inspect the class of `wf`:
139142

140143
```{r}
141144
wf %>% class() # class before
142-
workflows::remove_recipe(wf) %>% class() # class after removing recipe using workflows function
145+
remove_recipe(wf) %>% class() # class after removing recipe using workflows function
143146
```
144147

145148
We can observe that `wf` is no longer an `epi_workflow` and a `workflow`. It has
@@ -167,7 +170,7 @@ fit as before:
167170

168171
```{r}
169172
# fit linear model
170-
wf <- Update_model(wf, parsnip::linear_reg()) %>% fit(jhu)
173+
wf <- Update_model(wf, linear_reg()) %>% fit(jhu)
171174
wf
172175
```
173176

@@ -243,8 +246,8 @@ number in the order of operations, which can be obtained by inspecting `r2` or
243246
the tidy summary of it:
244247

245248
```{r}
246-
workflows::extract_preprocessor(wf) # step_epi_ahead is the third step in r2
247-
tidy(workflows::extract_preprocessor(wf)) # tidy tibble summary of r2
249+
extract_preprocessor(wf) # step_epi_ahead is the third step in r2
250+
tidy(extract_preprocessor(wf)) # tidy tibble summary of r2
248251
249252
wf <- wf %>% adjust_epi_recipe(which_step = 3, ahead = 14)
250253
```
@@ -268,7 +271,7 @@ variable, we would specify the step number of 2 in `which_step`.
268271
```{r}
269272
wf <- wf %>% adjust_epi_recipe(which_step = 2, lag = c(0, 1, 7, 14, 21))
270273
271-
workflows::extract_preprocessor(wf)
274+
extract_preprocessor(wf)
272275
```
273276

274277
We could adjust a recipe directly in the same way as we adjust a recipe in a
@@ -289,7 +292,7 @@ with a new `epi_recipe` that has undergone the adjustment
289292
```{r}
290293
r2 <- adjust_epi_recipe(r2, which_step = 2, lag = 0:21)
291294
292-
workflows::extract_preprocessor(wf)
295+
extract_preprocessor(wf)
293296
```
294297

295298
## Adjust a single layer of a `frosting`

0 commit comments

Comments
 (0)