Skip to content

Commit b1882cf

Browse files
committed
fix: updates from review
1 parent dc457b0 commit b1882cf

File tree

8 files changed

+170
-187
lines changed

8 files changed

+170
-187
lines changed

DEVELOPMENT.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,25 @@ devtools::check(vignettes = FALSE) # check package without vignettes
2121

2222
## Developing the documentation site
2323

24-
Our CI builds two version of the documentation:
24+
Our CI builds two versions of the documentation:
2525

2626
- https://cmu-delphi.github.io/epipredict/ from the `main` branch and
2727
- https://cmu-delphi.github.io/epipredict/dev from the `dev` branch.
2828

29-
We include the script `pkgdown-watch.R` that will automatically rebuild the
30-
documentation locally and preview it. It can be used with:
29+
Commands for developing the documentation site:
3130

3231
```sh
33-
# Make sure you have servr installed
34-
R -e 'renv::install("servr")'
35-
# Will start a local server
36-
Rscript pkgdown-watch.R
37-
# You may need to first build the site with
32+
# Basic build and preview
33+
R -e 'pkgdown::clean_site()'
34+
R -e 'devtools::document()'
35+
R -e 'pkgdown::build_site()'
36+
37+
# A smart rebuild workflow for non-RStudio users.
38+
# You may need to first build the site.
3839
R -e 'pkgdown::build_site(".", examples = FALSE, devel = TRUE, preview = FALSE)'
40+
R -e 'renv::install("servr")'
41+
# Will start a local docs server and monitor for changes.
42+
Rscript inst/pkgdown-watch.R
3943
```
4044

4145
## Versioning

pkgdown-watch.r renamed to inst/pkgdown-watch.r

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#
77
# Note that the `pattern` regex is case sensitive, so make sure your Rmd files
88
# end in `.Rmd` and not `.rmd`.
9+
#
10+
# Also I had issues with `pkgdown::build_reference()` not working, so I just run
11+
# it manually when I need to.
912

1013
rlang::check_installed(c("pkgdown", "servr", "devtools", "here", "cli", "fs"))
1114

@@ -32,7 +35,7 @@ servr::httw(
3235

3336
refs <- grep("man.+R(m?d)?$", files, value = TRUE)
3437
if (length(refs)) {
35-
# TODO: This does not work for me, so I just run it manually.
38+
# Doesn't work for me, so I run it manually.
3639
# pkgdown::build_reference(pkg, preview = FALSE, examples = FALSE, lazy = FALSE)
3740
}
3841

vignettes/arx-classifier.Rmd

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,8 @@ vignette: >
77
%\VignetteEncoding{UTF-8}
88
---
99

10-
```{r setup, include = FALSE}
11-
knitr::opts_chunk$set(
12-
echo = TRUE,
13-
collapse = FALSE,
14-
comment = "#>",
15-
warning = FALSE,
16-
message = FALSE,
17-
out.width = "100%"
18-
)
10+
```{r, include = FALSE}
11+
source("_common.R")
1912
```
2013

2114
## Load required packages

vignettes/backtesting.Rmd

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ vignette: >
77
%\VignetteEncoding{UTF-8}
88
---
99

10-
```{r setup, include = FALSE}
11-
source(here::here("vignettes", "_common.R"))
10+
```{r, include = FALSE}
11+
source("_common.R")
1212
```
1313

1414
```{r pkgs, include=FALSE, echo=TRUE}
@@ -132,16 +132,20 @@ Let's use the `epix_as_of()` method to generate a snapshot of the archive at the
132132
last date, and then run the forecaster.
133133

134134
```{r}
135+
# Let's forecast 14 days prior to the last date in the archive, to compare.
136+
forecast_date <- archive_cases_dv_subset$versions_end - 14
135137
# The .versions argument selects only the last version in the archive and
136138
# produces a forecast only on that date.
137139
forecasts <- archive_cases_dv_subset %>%
138140
epix_slide(
139141
~ arx_forecaster(
140142
.x,
141143
outcome = "percent_cli",
142-
predictors = c("case_rate_7d_av", "percent_cli")
143-
)$predictions,
144-
.versions = archive_cases_dv_subset$versions_end
144+
predictors = c("case_rate_7d_av", "percent_cli"),
145+
args_list = arx_args_list()
146+
)$predictions %>%
147+
pivot_quantiles_wider(.pred_distn),
148+
.versions = forecast_date
145149
)
146150
# Join the forecasts with with the latest data at the time of the forecast to
147151
# compare. Since `percent_cli` data has a few days of lag, we use `tidyr::fill` to
@@ -152,9 +156,9 @@ forecasts %>%
152156
epix_as_of(archive_cases_dv_subset$versions_end) %>%
153157
group_by(geo_value) %>%
154158
tidyr::fill(percent_cli),
155-
by = c("geo_value", "forecast_date" = "time_value")
159+
by = c("geo_value", "target_date" = "time_value")
156160
) %>%
157-
select(geo_value, forecast_date, .pred, .pred_distn, percent_cli)
161+
select(geo_value, forecast_date, .pred, `0.05`, `0.95`, percent_cli)
158162
```
159163

160164
The resulting epi_df now contains two new columns: `.pred` and `.pred_distn`,

vignettes/epipredict.Rmd

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ vignette: >
88
---
99

1010
```{r, include = FALSE}
11-
knitr::opts_chunk$set(
12-
echo = TRUE,
13-
collapse = TRUE,
14-
comment = "#>",
15-
out.width = "100%"
16-
)
11+
source("_common.R")
1712
```
1813

1914
```{r setup, message=FALSE}

0 commit comments

Comments
 (0)