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

Issue 486: Fix NOTEs for CRAN submission #514

Merged
merged 6 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
^\.devcontainer$
^CODE_OF_CONDUCT\.md$
^inst/manuscript/output$
^CRAN-SUBMISSION$
4 changes: 3 additions & 1 deletion R/avail_forecasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#' @export
#' @keywords check-forecasts
#' @examples
#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN
#' \dontshow{
#' data.table::setDTthreads(2) # restricts number of cores used on CRAN
#' }
#'
#' avail_forecasts(example_quantile,
#' collapse = c("quantile"),
Expand Down
4 changes: 3 additions & 1 deletion R/pairwise-comparisons.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
#' @author Johannes Bracher, \email{johannes.bracher@@kit.edu}
#' @keywords scoring
#' @examples
#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN
#' \dontshow{
#' data.table::setDTthreads(2) # restricts number of cores used on CRAN
#' }
#'
#' scores <- score(example_quantile)
#' pairwise <- pairwise_comparison(scores, by = "target_type")
Expand Down Expand Up @@ -227,8 +229,8 @@

# make result character instead of factor
result[, `:=`(
"model" = as.character(model),

Check warning on line 232 in R/pairwise-comparisons.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/pairwise-comparisons.R,line=232,col=5,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
"compare_against" = as.character(compare_against)

Check warning on line 233 in R/pairwise-comparisons.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/pairwise-comparisons.R,line=233,col=5,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
)]

# calculate relative skill as geometric mean
Expand Down
4 changes: 3 additions & 1 deletion R/pit.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
#' @seealso [pit()]
#' @importFrom stats runif
#' @examples
#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN
#' \dontshow{
#' data.table::setDTthreads(2) # restricts number of cores used on CRAN
#' }
#'
#' ## continuous predictions
#' true_values <- rnorm(20, mean = 1:20)
Expand Down Expand Up @@ -125,7 +127,7 @@

# check data type ------------------------------------------------------------
# check whether continuous or integer
if (!isTRUE(all.equal(as.vector(predictions), as.integer(predictions)))) {

Check warning on line 130 in R/pit.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/pit.R,line=130,col=7,[if_not_else_linter] In a simple if/else statement, prefer `if (A) x else y` to the less-readable `if (!A) y else x`.
continuous_predictions <- TRUE
} else {
continuous_predictions <- FALSE
Expand Down Expand Up @@ -217,7 +219,7 @@
value.var = "prediction"
)

pit <- data_wide[, .("pit_value" = pit_sample(

Check warning on line 222 in R/pit.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/pit.R,line=222,col=24,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
true_values = true_value,
predictions = as.matrix(.SD)
)),
Expand Down
12 changes: 9 additions & 3 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#' @examples
#' library(ggplot2)
#' library(magrittr) # pipe operator
#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN
#' \dontshow{
#' data.table::setDTthreads(2) # restricts number of cores used on CRAN
#' }
#'
#' scores <- score(example_quantile) %>%
#' summarise_scores(by = c("model", "target_type")) %>%
Expand Down Expand Up @@ -470,7 +472,7 @@
# it separately here to deal with the case when only the median is provided
# (in which case ggdist::geom_lineribbon() will fail)
if (0 %in% range) {
select_median <- (forecasts$range %in% 0 & forecasts$boundary == "lower")

Check warning on line 475 in R/plot.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/plot.R,line=475,col=23,[scalar_in_linter] Use == to match length-1 scalars, not %in%. Note that == preserves NA where %in% does not.
median <- forecasts[select_median]

if (nrow(median) > 0) {
Expand Down Expand Up @@ -582,7 +584,9 @@
#' @importFrom data.table dcast
#' @export
#' @examples
#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN
#' \dontshow{
#' data.table::setDTthreads(2) # restricts number of cores used on CRAN
#' }
#' scores <- score(example_quantile)
#' scores <- summarise_scores(scores, by = c("model", "range"))
#' plot_interval_coverage(scores)
Expand Down Expand Up @@ -835,7 +839,9 @@
#' @importFrom stats density
#' @return vector with the scoring values
#' @examples
#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN
#' \dontshow{
#' data.table::setDTthreads(2) # restricts number of cores used on CRAN
#' }
#'
#' # PIT histogram in vector based format
#' true_values <- rnorm(30, mean = 1:30)
Expand Down
4 changes: 3 additions & 1 deletion R/score.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
#'
#' @examples
#' library(magrittr) # pipe operator
#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN
#' \dontshow{
#' data.table::setDTthreads(2) # restricts number of cores used on CRAN
#' }
#'
#' check_forecasts(example_quantile)
#' score(example_quantile) %>%
Expand Down
7 changes: 6 additions & 1 deletion R/summarise_scores.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
#' provided to `fun`. For more information see the documentation of the
#' respective function.
#' @examples
#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN
#' \dontshow{
#' data.table::setDTthreads(2) # restricts number of cores used on CRAN
#' }
#' library(magrittr) # pipe operator
#'
#' scores <- score(example_continuous)
Expand Down Expand Up @@ -279,6 +281,9 @@ check_summary_params <- function(scores,
#' summary is present according to the value specified in `by`.
#' @examples
#' library(magrittr) # pipe operator
#' \dontshow{
#' data.table::setDTthreads(2) # restricts number of cores used on CRAN
#' }
#' score(example_quantile) %>%
#' add_coverage(by = c("model", "target_type")) %>%
#' summarise_scores(by = c("model", "target_type")) %>%
Expand Down
3 changes: 3 additions & 0 deletions man/add_coverage.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/avail_forecasts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/pairwise_comparison.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/pit_sample.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/plot_interval_coverage.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/plot_pit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/plot_score_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/score.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/summarise_scores.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# load common required test packages
library(ggplot2, quietly = TRUE)
suppressMessages(library(magrittr))
data.table::setDTthreads(2) # restricts number of cores used on CRAN

# compute quantile scores
scores <- suppressMessages(score(example_quantile))
scores <- suppressMessages(score(example_quantile))
3 changes: 2 additions & 1 deletion vignettes/scoringutils.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ library(magrittr)
library(data.table)
library(ggplot2)
library(knitr)
data.table::setDTthreads(2) # restricts number of cores used on CRAN
seabbs marked this conversation as resolved.
Show resolved Hide resolved
```

The `scoringutils` package provides a collection of metrics and proper scoring rules that make it simple to score probabilistic forecasts against the true observed values. You can find more information in the paper [Evaluating Forecasts with scoringutils in R](https://arxiv.org/abs/2205.07090) as well as the [Metrics-Vignette](https://epiforecasts.io/scoringutils/articles/metric-details.html) and the [Scoring forecasts directly Vignette](https://epiforecasts.io/scoringutils/articles/scoring-forecasts-directly.html).
Expand All @@ -35,7 +36,7 @@ Most of the time, the `score()` function will be able to do the entire evaluatio

```{r, echo=FALSE}
requirements <- data.table(
"Format" = c(
Format = c(
"quantile-based", "sample-based", "binary", "pairwise-comparisons"
),
`Required columns` = c(
Expand Down
Loading