Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update suggests #917

Merged
merged 6 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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