diff --git a/.buildlibrary b/.buildlibrary index b6866c7..3d921b6 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '618891372' +ValidationKey: '619854900' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index 1685378..3f0ed9e 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'quitte: Bits and pieces of code to use with quitte-style data frames' -version: 0.3128.4 -date-released: '2024-03-01' +version: 0.3129.0 +date-released: '2024-03-28' abstract: A collection of functions for easily dealing with quitte-style data frames, doing multi-model comparisons and plots. authors: diff --git a/DESCRIPTION b/DESCRIPTION index 8876ae2..e96f5e8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: quitte Title: Bits and pieces of code to use with quitte-style data frames -Version: 0.3128.4 -Date: 2024-03-01 +Version: 0.3129.0 +Date: 2024-03-28 Authors@R: c( person("Michaja", "Pehl", , "pehl@pik-potsdam.de", role = c("aut", "cre")), person("Nico", "Bauer", , "nicolasb@pik-potsdam.de", role = "aut"), diff --git a/R/calc_addVariable.R b/R/calc_addVariable.R index c98a7c5..9a19637 100644 --- a/R/calc_addVariable.R +++ b/R/calc_addVariable.R @@ -54,6 +54,8 @@ #' @param overwrite If `TRUE` (the default), values are overwritten if they #' already exist. If `FALSE` values are discarded and not overwritten if they #' already exist +#' @param skip.fails If `FALSE` (the default), fail if any right-hand-side variable is missing +#' If `TRUE`, just skip that calculation. #' @param .dots Used to work around non-standard evaluation. See details. #' #' @return A data frame. @@ -93,7 +95,7 @@ calc_addVariable <- function(data, ..., units = NA, na.rm = TRUE, completeMissing = FALSE, only.new = FALSE, variable = variable, unit = unit, - value = value, overwrite = TRUE) { + value = value, overwrite = TRUE, skip.fails = FALSE) { .dots <- list(...) @@ -113,7 +115,7 @@ calc_addVariable <- function(data, ..., units = NA, na.rm = TRUE, value <- deparse(substitute(value)) calc_addVariable_(data, .dots, na.rm, completeMissing, only.new, variable, - unit, value, overwrite) + unit, value, overwrite, skip.fails) } #' @export @@ -121,7 +123,7 @@ calc_addVariable <- function(data, ..., units = NA, na.rm = TRUE, calc_addVariable_ <- function(data, .dots, na.rm = TRUE, completeMissing = FALSE, only.new = FALSE, variable = 'variable', unit = 'unit', - value = 'value', overwrite = TRUE) { + value = 'value', overwrite = TRUE, skip.fails = FALSE) { . <- NULL # guardians ---- @@ -181,10 +183,14 @@ calc_addVariable_ <- function(data, .dots, na.rm = TRUE, missing_rhs_variables <- setdiff(.dots[[i]]$variables, data_work[[variable]]) if (0 < length(missing_rhs_variables)) { - stop(length(missing_rhs_variables), ' variable', - ifelse(1 < length(missing_rhs_variables), 's are', ' is'), - ' missing for the calculation:\n', - paste(paste0('`', missing_rhs_variables, '`'), collapse = '\n')) + if (isTRUE(skip.fails)) { + next + } else { + stop(length(missing_rhs_variables), ' variable', + ifelse(1 < length(missing_rhs_variables), 's are', ' is'), + ' missing for the calculation:\n', + paste(paste0('`', missing_rhs_variables, '`'), collapse = '\n')) + } } data_work <- bind_rows( diff --git a/README.md b/README.md index 561ad59..0fe0b30 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Bits and pieces of code to use with quitte-style data frames -R package **quitte**, version **0.3128.4** +R package **quitte**, version **0.3129.0** [![CRAN status](https://www.r-pkg.org/badges/version/quitte)](https://cran.r-project.org/package=quitte) [![R build status](https://github.com/pik-piam/quitte/workflows/check/badge.svg)](https://github.com/pik-piam/quitte/actions) [![codecov](https://codecov.io/gh/pik-piam/quitte/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/quitte) [![r-universe](https://pik-piam.r-universe.dev/badges/quitte)](https://pik-piam.r-universe.dev/builds) @@ -47,7 +47,7 @@ In case of questions / problems please contact Michaja Pehl . +Pehl M, Bauer N, Hilaire J, Levesque A, Luderer G, Schultes A, Dietrich J, Richters O (2024). _quitte: Bits and pieces of code to use with quitte-style data frames_. R package version 0.3129.0, . A BibTeX entry for LaTeX users is @@ -56,7 +56,7 @@ A BibTeX entry for LaTeX users is title = {quitte: Bits and pieces of code to use with quitte-style data frames}, author = {Michaja Pehl and Nico Bauer and Jérôme Hilaire and Antoine Levesque and Gunnar Luderer and Anselm Schultes and Jan Philipp Dietrich and Oliver Richters}, year = {2024}, - note = {R package version 0.3128.4}, + note = {R package version 0.3129.0}, url = {https://github.com/pik-piam/quitte}, } ``` diff --git a/man/calc_addVariable.Rd b/man/calc_addVariable.Rd index 319e3bb..f425c35 100644 --- a/man/calc_addVariable.Rd +++ b/man/calc_addVariable.Rd @@ -15,7 +15,8 @@ calc_addVariable( variable = variable, unit = unit, value = value, - overwrite = TRUE + overwrite = TRUE, + skip.fails = FALSE ) calc_addVariable_( @@ -27,7 +28,8 @@ calc_addVariable_( variable = "variable", unit = "unit", value = "value", - overwrite = TRUE + overwrite = TRUE, + skip.fails = FALSE ) } \arguments{ @@ -64,6 +66,9 @@ column).} already exist. If \code{FALSE} values are discarded and not overwritten if they already exist} +\item{skip.fails}{If \code{FALSE} (the default), fail if any right-hand-side variable is missing +If \code{TRUE}, just skip that calculation.} + \item{.dots}{Used to work around non-standard evaluation. See details.} } \value{