From 1c040b67a34aae746b80a9c3ee6ce98896e91e08 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Mon, 8 Jan 2024 19:02:09 +0100 Subject: [PATCH] Release/0.3.0 cran update (#449) * Update examples to `dontrun` for CRAN * Update documentation * reformat NEWS.md and update wordlist * Add .onLoad to ensure that CRAN checks don't yuse more than 2 CPUs --- NEWS.md | 4 ++-- R/join_ald_scenario.R | 2 ++ R/r2dii.analysis-package.R | 9 +++++++++ R/summarize_weighted_production.R | 2 ++ R/target_market_share.R | 2 ++ R/target_sda.R | 3 ++- inst/WORDLIST | 4 ++++ man/join_ald_scenario.Rd | 2 ++ man/summarize_weighted_production.Rd | 2 ++ man/target_market_share.Rd | 2 ++ man/target_sda.Rd | 3 ++- 11 files changed, 31 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7613b1c6..704a6f4c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,7 @@ # r2dii.analysis 0.3.0 -# `target_sda` now uses final year of scenario as convergence target when `by_company = TRUE` (#445). -# `target_market_share` gains argument `increasing_or_decreasing` (#426). +* `target_sda` now uses final year of scenario as convergence target when `by_company = TRUE` (#445). +* `target_market_share` gains argument `increasing_or_decreasing` (#426). # r2dii.analysis 0.2.1 diff --git a/R/join_ald_scenario.R b/R/join_ald_scenario.R index f2f3be96..0cd1943f 100644 --- a/R/join_ald_scenario.R +++ b/R/join_ald_scenario.R @@ -11,6 +11,7 @@ #' @export #' #' @examples +#' \dontrun{ #' installed <- requireNamespace("r2dii.data", quietly = TRUE) && #' requireNamespace("r2dii.match", quietly = TRUE) && #' packageVersion("r2dii.match") >= "0.1.0" @@ -38,6 +39,7 @@ #' region_isos = region_isos_demo #' ) #' } +#' } join_ald_scenario <- function(data, ald, scenario, diff --git a/R/r2dii.analysis-package.R b/R/r2dii.analysis-package.R index 21d5b74d..1aa2bda4 100644 --- a/R/r2dii.analysis-package.R +++ b/R/r2dii.analysis-package.R @@ -1,6 +1,15 @@ #' @keywords internal "_PACKAGE" +.onLoad <- function(libname, pkgname) { + # CRAN OMP THREAD LIMIT + # logic for setting OMP_THREAD_LIMIT form https://stackoverflow.com/a/77323812 + # check modified from testthat's on_cran function + if (!interactive() && isFALSE(as.logical(Sys.getenv("NOT_CRAN", "false")))) { + Sys.setenv("OMP_THREAD_LIMIT" = 2) + } +} + # The following block is used by usethis to automatically manage # roxygen namespace tags. Modify with care! ## usethis namespace: start diff --git a/R/summarize_weighted_production.R b/R/summarize_weighted_production.R index b693154f..cb5f21e3 100644 --- a/R/summarize_weighted_production.R +++ b/R/summarize_weighted_production.R @@ -27,6 +27,7 @@ #' `summarize_weighted_percent_change()`, respectively. #' #' @examples +#' \dontrun{ #' installed <- requireNamespace("r2dii.data", quietly = TRUE) && #' requireNamespace("r2dii.match", quietly = TRUE) && #' packageVersion("r2dii.match") >= "0.1.0" @@ -55,6 +56,7 @@ #' #' summarize_weighted_percent_change(master, use_credit_limit = TRUE) #' } +#' } summarize_weighted_production <- function(data, ..., use_credit_limit = FALSE) { summarize_weighted_production_(data, ..., use_credit_limit = use_credit_limit, with_targets = FALSE) } diff --git a/R/target_market_share.R b/R/target_market_share.R index 37be4846..8868cd92 100644 --- a/R/target_market_share.R +++ b/R/target_market_share.R @@ -33,6 +33,7 @@ #' @family functions to calculate scenario targets #' #' @examples +#' \dontrun{ #' installed <- requireNamespace("r2dii.data", quietly = TRUE) && #' requireNamespace("r2dii.match", quietly = TRUE) && #' packageVersion("r2dii.match") >= "0.1.0" @@ -74,6 +75,7 @@ #' weight_production = FALSE #' ) #' } +#' } target_market_share <- function(data, abcd, scenario, diff --git a/R/target_sda.R b/R/target_sda.R index e46cd760..e40dd4f5 100644 --- a/R/target_sda.R +++ b/R/target_sda.R @@ -33,6 +33,7 @@ #' @family functions to calculate scenario targets #' #' @examples +#' \dontrun{ #' installed <- requireNamespace("r2dii.match", quietly = TRUE) && #' requireNamespace("r2dii.data", quietly = TRUE) && #' packageVersion("r2dii.match") >= "0.1.0" @@ -65,7 +66,7 @@ #' by_company = TRUE #' ) #' } -#' +#' } target_sda <- function(data, abcd, co2_intensity_scenario, diff --git a/inst/WORDLIST b/inst/WORDLIST index e458d603..3634767f 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -6,6 +6,7 @@ Codecov Decarbonization IKI Lifecycle +Metaprogramming ORCID PACTA PACTA’ @@ -14,6 +15,7 @@ SDA Sectoral WRI WWF +abcd ald decarbonization dev @@ -21,6 +23,7 @@ dfrac dii dplyr eval +favour frac funder funders @@ -34,6 +37,7 @@ roadmaps rstudio sectoral smsp +summarise tibble tidyverse tmsr diff --git a/man/join_ald_scenario.Rd b/man/join_ald_scenario.Rd index cfa5a8ed..84ee153f 100644 --- a/man/join_ald_scenario.Rd +++ b/man/join_ald_scenario.Rd @@ -19,6 +19,7 @@ This function was deprecated in favour of \code{\link[=join_abcd_scenario]{join_ for more information. } \examples{ +\dontrun{ installed <- requireNamespace("r2dii.data", quietly = TRUE) && requireNamespace("r2dii.match", quietly = TRUE) && packageVersion("r2dii.match") >= "0.1.0" @@ -47,4 +48,5 @@ if (installed) { ) } } +} \keyword{internal} diff --git a/man/summarize_weighted_production.Rd b/man/summarize_weighted_production.Rd index 6118e4a6..19661a9f 100644 --- a/man/summarize_weighted_production.Rd +++ b/man/summarize_weighted_production.Rd @@ -37,6 +37,7 @@ companies would cause percent-change percentage to be infinite, which is wrong. } \examples{ +\dontrun{ installed <- requireNamespace("r2dii.data", quietly = TRUE) && requireNamespace("r2dii.match", quietly = TRUE) && packageVersion("r2dii.match") >= "0.1.0" @@ -66,6 +67,7 @@ if (installed) { summarize_weighted_percent_change(master, use_credit_limit = TRUE) } } +} \seealso{ \code{\link[=join_abcd_scenario]{join_abcd_scenario()}}. diff --git a/man/target_market_share.Rd b/man/target_market_share.Rd index 640d041c..a315179a 100644 --- a/man/target_market_share.Rd +++ b/man/target_market_share.Rd @@ -60,6 +60,7 @@ This function ignores existing groups and outputs ungrouped data. } \examples{ +\dontrun{ installed <- requireNamespace("r2dii.data", quietly = TRUE) && requireNamespace("r2dii.match", quietly = TRUE) && packageVersion("r2dii.match") >= "0.1.0" @@ -102,6 +103,7 @@ if (installed) { ) } } +} \seealso{ Other functions to calculate scenario targets: \code{\link{target_sda}()} diff --git a/man/target_sda.Rd b/man/target_sda.Rd index a53f13e7..dd073306 100644 --- a/man/target_sda.Rd +++ b/man/target_sda.Rd @@ -54,6 +54,7 @@ This function ignores existing groups and outputs ungrouped data. } \examples{ +\dontrun{ installed <- requireNamespace("r2dii.match", quietly = TRUE) && requireNamespace("r2dii.data", quietly = TRUE) && packageVersion("r2dii.match") >= "0.1.0" @@ -86,7 +87,7 @@ if (installed) { by_company = TRUE ) } - +} } \seealso{ Other functions to calculate scenario targets: