From 620f3caeca85c20f9bc771cc75c4a13f21e6c27e Mon Sep 17 00:00:00 2001 From: Debbora Leip Date: Tue, 12 Mar 2024 15:36:07 +0100 Subject: [PATCH] bugfix in fix of aggregation weight --- .buildlibrary | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- R/calcValidFactorReqShares.R | 3 ++- README.md | 6 +++--- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index b376120..4aba3ec 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '50791404' +ValidationKey: '50811198' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 6facd9f..0ce9345 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,7 +2,7 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'mrvalidation: madrat data preparation for validation purposes' -version: 2.56.6 +version: 2.56.7 date-released: '2024-03-12' abstract: Package contains routines to prepare data for validation exercises. authors: diff --git a/DESCRIPTION b/DESCRIPTION index ed09a8d..7f23843 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mrvalidation Title: madrat data preparation for validation purposes -Version: 2.56.6 +Version: 2.56.7 Date: 2024-03-12 Authors@R: c( person("Benjamin Leon", "Bodirsky", , "bodirsky@pik-potsdam.de", role = c("aut", "cre")), diff --git a/R/calcValidFactorReqShares.R b/R/calcValidFactorReqShares.R index 6f00600..3e65ae7 100644 --- a/R/calcValidFactorReqShares.R +++ b/R/calcValidFactorReqShares.R @@ -40,8 +40,9 @@ calcValidFactorReqShares <- function(subtype = "crop") { if (any(missingYears > min(getYears(weight, as.integer = TRUE)))) { stop("Need to fix weight for new years not covered in factor costs dataset") } + minYear <- min(getYears(weight, as.integer = TRUE)) weight <- magpiesort(add_columns(weight, dim = 2, addnm = paste0("y", missingYears))) - weight[, missingYears, ] <- weight[, min(getYears(weight, as.integer = TRUE)), ] + weight[, missingYears, ] <- weight[, minYear, ] # Give 0 weigh to countries with unexpectedly high capital shares weight[c("BLZ", "CRI", "DOM", "HND", "JAM", "MEX", "NIC", "PAN", "SLV"), , ] <- 0 diff --git a/README.md b/README.md index af60aab..9d560d6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat data preparation for validation purposes -R package **mrvalidation**, version **2.56.6** +R package **mrvalidation**, version **2.56.7** [![CRAN status](https://www.r-pkg.org/badges/version/mrvalidation)](https://cran.r-project.org/package=mrvalidation) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4317826.svg)](https://doi.org/10.5281/zenodo.4317826) [![R build status](https://github.com/pik-piam/mrvalidation/workflows/check/badge.svg)](https://github.com/pik-piam/mrvalidation/actions) [![codecov](https://codecov.io/gh/pik-piam/mrvalidation/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrvalidation) [![r-universe](https://pik-piam.r-universe.dev/badges/mrvalidation)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Benjamin Leon Bodirsky . +Bodirsky B, Wirth S, Karstens K, Humpenoeder F, Stevanovic M, Mishra A, Biewald A, Weindl I, Beier F, Chen D, Crawford M, Leip D, Molina Bacca E, Kreidenweis U, W. Yalew A, von Jeetze P, Wang X, Dietrich J, Alves M (2024). _mrvalidation: madrat data preparation for validation purposes_. doi: 10.5281/zenodo.4317826 (URL: https://doi.org/10.5281/zenodo.4317826), R package version 2.56.7, . A BibTeX entry for LaTeX users is @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is title = {mrvalidation: madrat data preparation for validation purposes}, author = {Benjamin Leon Bodirsky and Stephen Wirth and Kristine Karstens and Florian Humpenoeder and Mishko Stevanovic and Abhijeet Mishra and Anne Biewald and Isabelle Weindl and Felicitas Beier and David Chen and Michael Crawford and Debbora Leip and Edna {Molina Bacca} and Ulrich Kreidenweis and Amsalu {W. Yalew} and Patrick {von Jeetze} and Xiaoxi Wang and Jan Philipp Dietrich and Marcos Alves}, year = {2024}, - note = {R package version 2.56.6}, + note = {R package version 2.56.7}, doi = {10.5281/zenodo.4317826}, url = {https://github.com/pik-piam/mrvalidation}, }