Skip to content

Commit

Permalink
Merge pull request #917 from epiforecasts/update-suggests
Browse files Browse the repository at this point in the history
Update suggests
  • Loading branch information
nikosbosse authored Sep 23, 2024
2 parents 9d28b4b + f87fe68 commit fb58190
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
extra-packages: any::rcmdcheck, ggdist=?ignore-before-r=4.1.0
needs: check

- uses: r-lib/actions/check-r-package@v2
Expand Down
13 changes: 7 additions & 6 deletions vignettes/Deprecated-visualisations.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ The example data used is the data shipped with the `scoringutils` package. It co
library(scoringutils)
library(data.table)
library(ggplot2)
library(ggdist)
library(magrittr)
library(magrittr) #pipe operator
```
Expand All @@ -35,7 +34,7 @@ library(magrittr) #pipe operator

In previous versions of `scoringutils`, forecasts and observed values could be visualised using the function `plot_predictions()` and its `make_na()` helper function. The following shows the function code first and then an example.

```{r}
```{r eval=!require("ggdist", quietly = TRUE)}
#" @title Plot Predictions vs True Values
#"
#" @description
Expand Down Expand Up @@ -98,6 +97,8 @@ In previous versions of `scoringutils`, forecasts and observed values could be v
#" facet_wrap(~ location + target_type, scales = "free_y") +
#" aes(fill = model, color = model)
library(ggdist)
plot_predictions <- function(data,
by = NULL,
x = "date",
Expand Down Expand Up @@ -277,7 +278,7 @@ In the following are a few examples of using the two functions to create a plot

Visualising the median forecasts for the example data. The truth data is restricted to a period between 2021-05-01 and 2021-07-22. The forecast data is a forecast from the model "EuroCOVIDhub-ensemble" made on the "2021-06-07". All other data is set to `NA`, effectively removing it from the plot.

```{r}
```{r eval=!require("ggdist", quietly = TRUE)}
median_forecasts <- example_quantile[quantile_level == 0.5]
median_forecasts %>%
make_NA(what = "truth",
Expand All @@ -295,7 +296,7 @@ median_forecasts %>%

This is the same plot, but with a variety of prediction intervals shown, instead of just the median.

```{r}
```{r eval=!require("ggdist", quiet = TRUE)}
example_quantile %>%
make_NA(what = "truth",
target_end_date <= "2021-05-01",
Expand All @@ -313,7 +314,7 @@ example_quantile %>%

And a similar plot, this time based on continuous forecasts. The predictions are automatically converted to a quantile-based forecasts for plotting.

```{r}
```{r eval=!require("ggdist", quietly = TRUE)}
example_sample_continuous %>%
make_NA(what = "truth",
target_end_date <= "2021-05-01",
Expand All @@ -331,7 +332,7 @@ example_sample_continuous %>%

Displaying two forecasts at a time with additional colours:

```{r}
```{r eval=!require("ggdist", quietly = TRUE)}
example_quantile %>%
make_NA(what = "truth",
target_end_date > "2021-07-15",
Expand Down

0 comments on commit fb58190

Please sign in to comment.