diff --git a/.buildlibrary b/.buildlibrary index b7c89f1..1400b2b 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '52359240' +ValidationKey: '52426361' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' @@ -8,3 +8,4 @@ AcceptedNotes: - Depends: includes the non-default packages allowLinterWarnings: no enforceVersionUpdate: no +skipCoverage: no diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 23545e6..d85a316 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -63,6 +63,6 @@ jobs: shell: Rscript {0} run: | nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps")) - if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE) + if(length(nonDummyTests) > 0 && !lucode2:::loadBuildLibraryConfig()[["skipCoverage"]]) covr::codecov(quiet = FALSE) env: NOT_CRAN: "true" diff --git a/CITATION.cff b/CITATION.cff index 9ffaabb..b9ed29b 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: 'mrvalidation: madrat data preparation for validation purposes' -version: 2.61.6 -date-released: '2024-10-19' +version: 2.61.7 +date-released: '2024-11-06' abstract: Package contains routines to prepare data for validation exercises. authors: - family-names: Bodirsky diff --git a/DESCRIPTION b/DESCRIPTION index 9243274..bb59168 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrvalidation Title: madrat data preparation for validation purposes -Version: 2.61.6 -Date: 2024-10-19 +Version: 2.61.7 +Date: 2024-11-06 Authors@R: c( person("Benjamin Leon", "Bodirsky", , "bodirsky@pik-potsdam.de", role = c("aut", "cre")), person("Stephen", "Wirth", role = "aut"), @@ -34,7 +34,7 @@ Depends: madrat (>= 2.11.3), magclass (>= 3.17), mrcommons (>= 1.41.0), - mrdrivers (>= 0.2.2), + mrdrivers (>= 4.0.0), mrfactors (>= 0.4.0), mrfaocore (>= 1.0.0), mrlandcore (>= 1.0.0), diff --git a/NAMESPACE b/NAMESPACE index d27b622..c656a67 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -38,13 +38,11 @@ importFrom(madrat,toolGetMapping) importFrom(madrat,toolNAreplace) importFrom(madrat,toolSplitSubtype) importFrom(madrat,toolSubtypeSelect) -importFrom(madrat,vcat) importFrom(magclass,"getCells<-") importFrom(magclass,"getComment<-") importFrom(magclass,"getItems<-") importFrom(magclass,"getNames<-") importFrom(magclass,"getRegions<-") -importFrom(magclass,"getSets<-") importFrom(magclass,"getYears<-") importFrom(magclass,add_columns) importFrom(magclass,add_dimension) diff --git a/R/calcValidIncome.R b/R/calcValidIncome.R index 63debb5..6f01185 100644 --- a/R/calcValidIncome.R +++ b/R/calcValidIncome.R @@ -3,17 +3,13 @@ #' Returns historical development of income and future projections of income dynamics #' #' -#' @param datasource To switch between historical values of James et al (default) or -#' with future projections for different scenarios (James_OECD_Nakicenovic) +#' @param datasource "WDI_SSPs", the only one option at the moment. #' @return list of magpie object with data and weight. Since intensive and extensive variables #' are mixed please keep the mixed_aggregation -#' @importFrom madrat vcat calcOutput -#' @importFrom magclass mbind add_dimension getSets getSets<- collapseNames getYears #' @author Florian Humpenoeder, Abhijeet Mishra, Kristine Karstens +calcValidIncome <- function(datasource = "WDI_SSPs") { -calcValidIncome <- function(datasource = "WDI-MI_SSPs-MI") { - - if (datasource == "WDI-MI_SSPs-MI") { + if (datasource == "WDI_SSPs") { .tmp <- function(x, nm) { getSets(x)[3] <- "scenario" @@ -64,10 +60,9 @@ calcValidIncome <- function(datasource = "WDI-MI_SSPs-MI") { stop("Given datasource currently not supported!") } - return(list(x = out, - weight = weight, - mixed_aggregation = TRUE, - unit = "(million) US Dollar 2017 equivalents in MER/yr, MER/cap/yr, PPP/yr, PPP/cap/yr", - description = "Income") - ) + list(x = out, + weight = weight, + mixed_aggregation = TRUE, + unit = "(million) US Dollar 2017 equivalents in MER/yr, MER/cap/yr, PPP/yr, PPP/cap/yr", + description = "Income") } diff --git a/R/calcValidPopulation.R b/R/calcValidPopulation.R index 3ae29c9..64a18f7 100644 --- a/R/calcValidPopulation.R +++ b/R/calcValidPopulation.R @@ -2,53 +2,31 @@ #' #' Returns historical development of population and future projections of population dynamics #' -#' -#' @param PopulationPast population past data source -#' @param PopulationFuture population future data source -#' @param TimeFromFindSet boolean deciding something +#' @param pastData population past data source +#' @param futureData population future data source #' @return list of magpie object with data and weight #' @author Florian Humpenoeder, Jan Philipp Dietrich, David Chen -#' @importFrom magclass getRegions -#' @import mrdrivers -calcValidPopulation <- function(PopulationPast = "WDI-UN_PopDiv-MI", - PopulationFuture = c("SSPs-UN_PopDiv-MI", - "SDPs-UN_PopDiv-MI", - "SSP2EU-UN_PopDiv-MI"), - TimeFromFindSet = TRUE) { - - past <- calcOutput("PopulationPast", - PopulationPast = PopulationPast, - aggregate = FALSE) - getNames(past) <- paste("historical", paste0(PopulationPast), "Population (million people)", sep = ".") - getSets(past)[3] <- "scenario.model.variable" +calcValidPopulation <- function(pastData = "WDI-UN_PopDiv-MI", futureData = "SSPs-UN_PopDiv") { - future <- NULL - for (i in 1:length(PopulationFuture)) { - tmp <- calcOutput("PopulationFuture", - PopulationFuture = PopulationFuture[i], - extension2150 = "bezier", - aggregate = FALSE) - future <- mbind(future, tmp) - } + past <- calcOutput("PopulationPast", pastData = pastData, aggregate = FALSE) + future <- calcOutput("PopulationFuture", futureData = futureData, aggregate = FALSE) - - getNames(future) <- paste(sub("^pop_", "", getNames(future)), - paste0(PopulationFuture, collapse = "_and_"), - "Population (million people)", - sep = ".") + getNames(past) <- paste("historical", pastData, "Population (million people)", sep = ".") + getNames(future) <- paste(getNames(future), futureData, "Population (million people)", sep = ".") + getSets(past)[3] <- "scenario.model.variable" getSets(future)[3] <- "scenario.model.variable" - out <- new.magpie(getRegions(past), - union(getYears(past), getYears(future)), - c(getNames(past), getNames(future)), + out <- new.magpie(cells_and_regions = getItems(past, 1), + years = union(getYears(past), getYears(future)), + names = c(getNames(past), getNames(future)), + sets = c("region", "year", "scenario.model.variable"), fill = NA) out[, getYears(past), getNames(past)] <- past out[, getYears(future), getNames(future)] <- future - getSets(out, fulldim = FALSE)[3] <- "scenario.model.variable" - return(list(x = out, weight = NULL, unit = "million", - description = paste0("Population data. Datasource for the Past: ", - PopulationPast, - ". Datasource for the Future: ", - paste0(PopulationFuture, collapse = ", ")))) + list(x = out, + weight = NULL, + unit = "million", + description = paste0("Population data. Datasource for the Past: ", pastData, ". Datasource for the Future: ", + futureData)) } diff --git a/README.md b/README.md index eae6ddc..4235053 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat data preparation for validation purposes -R package **mrvalidation**, version **2.61.6** +R package **mrvalidation**, version **2.61.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 , R package version 2.61.6, . +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 , R package version 2.61.7, . A BibTeX entry for LaTeX users is @@ -48,8 +48,8 @@ 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.61.6}, - url = {https://github.com/pik-piam/mrvalidation}, + note = {R package version 2.61.7}, doi = {10.5281/zenodo.4317826}, + url = {https://github.com/pik-piam/mrvalidation}, } ``` diff --git a/man/calcValidIncome.Rd b/man/calcValidIncome.Rd index 21fa845..1e3ba16 100644 --- a/man/calcValidIncome.Rd +++ b/man/calcValidIncome.Rd @@ -4,11 +4,10 @@ \alias{calcValidIncome} \title{calcValidIncome} \usage{ -calcValidIncome(datasource = "WDI-MI_SSPs-MI") +calcValidIncome(datasource = "WDI_SSPs") } \arguments{ -\item{datasource}{To switch between historical values of James et al (default) or -with future projections for different scenarios (James_OECD_Nakicenovic)} +\item{datasource}{"WDI_SSPs", the only one option at the moment.} } \value{ list of magpie object with data and weight. Since intensive and extensive variables diff --git a/man/calcValidPopulation.Rd b/man/calcValidPopulation.Rd index 6924361..538de8b 100644 --- a/man/calcValidPopulation.Rd +++ b/man/calcValidPopulation.Rd @@ -5,17 +5,14 @@ \title{calcValidPopulation} \usage{ calcValidPopulation( - PopulationPast = "WDI-UN_PopDiv-MI", - PopulationFuture = c("SSPs-UN_PopDiv-MI", "SDPs-UN_PopDiv-MI", "SSP2EU-UN_PopDiv-MI"), - TimeFromFindSet = TRUE + pastData = "WDI-UN_PopDiv-MI", + futureData = "SSPs-UN_PopDiv" ) } \arguments{ -\item{PopulationPast}{population past data source} +\item{pastData}{population past data source} -\item{PopulationFuture}{population future data source} - -\item{TimeFromFindSet}{boolean deciding something} +\item{futureData}{population future data source} } \value{ list of magpie object with data and weight