diff --git a/.buildlibrary b/.buildlibrary index 86c250c..41420f7 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '30175840' +ValidationKey: '30203379' 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 2eae0d9..178206e 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: 'mip: Comparison of multi-model runs' -version: 0.151.0 -date-released: '2024-09-18' +version: 0.151.1 +date-released: '2024-09-23' abstract: Package contains generic functions to produce comparison plots of multi-model runs. authors: diff --git a/DESCRIPTION b/DESCRIPTION index 56c41ae..784d24f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mip Title: Comparison of multi-model runs -Version: 0.151.0 -Date: 2024-09-18 +Version: 0.151.1 +Date: 2024-09-23 Authors@R: c( person("David", "Klein", , "dklein@pik-potsdam.de", role = c("aut", "cre")), person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = "aut"), diff --git a/R/mipArea.R b/R/mipArea.R index 4d4e5a9..72467f2 100644 --- a/R/mipArea.R +++ b/R/mipArea.R @@ -82,40 +82,34 @@ mipArea <- function(x, stack_priority = c("variable", "region"), total = TRUE, s ### ### Find out which variables to stack and which to put to facet_grid ### - if ("identifier" %in% names(x)) { - # if the identifier is specified externally, us that + region as facet and stack variables - facets <- c("identifier", "region") - if (!is.null(hist)) x <- rbind(x, hist) - dimToStack <- "variable" - } else { - # Identify stacking and facet_grid based on data - # count levels of the given columns - nLevels <- vapply(subset(x, select = c("variable", "region", "scenario", "model")), nlevels, integer(1)) - - # Find first dimension in stack_priority that has more than one element. - # Initialize dimToStack (this applies if if all dimensions have only one element) - dimToStack <- stack_priority[1] - for (s in stack_priority) { - if (nLevels[s] > 1) { - dimToStack <- s - break - } + + # count levels of the given columns + nLevels <- vapply(subset(x, select = c("variable", "region", "scenario", "model")), nlevels, integer(1)) + + # Find first dimension in stack_priority that has more than one element. + # Initialize dimToStack (this applies if if all dimensions have only one element) + dimToStack <- stack_priority[1] + for (s in stack_priority) { + if (nLevels[s] > 1) { + dimToStack <- s + break } + } - # find and sort dimension with more than one element, exclude dimToStack - # sort: to be able to build the interaction with the smallest number of resulting combinations (further down) - facets <- sort(nLevels[nLevels > 1]) - facets <- setdiff(names(facets), dimToStack) + # find and sort dimension with more than one element, exclude dimToStack + # sort: to be able to build the interaction with the smallest number of resulting combinations (further down) + facets <- sort(nLevels[nLevels > 1]) + facets <- setdiff(names(facets), dimToStack) - # Combine data and historical data into one object - if (!is.null(hist)) x <- rbind(x, hist) + # Combine data and historical data into one object + if (!is.null(hist)) x <- rbind(x, hist) - # if there are three facet dimensions that have more than one element combine the two - # smallest ones into the first one to be able to create a 2-D facet_grid later on - if (length(facets) == 3) { - x[, facets[1]] <- paste(x[[facets[2]]], x[[facets[1]]]) - } + # if there are three facet dimensions that have more than one element combine the two + # smallest ones into the first one to be able to create a 2-D facet_grid later on + if (length(facets) == 3) { + x[, facets[1]] <- paste(x[[facets[2]]], x[[facets[1]]]) } + # if not provided by user calculate total by summing over dimToStack if (isTRUE(total)) { dimToGroup <- setdiff(c("model", "scenario", "region", "variable", "unit", "period"), dimToStack) diff --git a/R/showAreaAndBarPlots.R b/R/showAreaAndBarPlots.R index ccca9d3..3739476 100644 --- a/R/showAreaAndBarPlots.R +++ b/R/showAreaAndBarPlots.R @@ -172,7 +172,6 @@ showAreaAndBarPlots <- function( .data$region == .env$mainReg, .data$variable == .env$tot) %>% droplevels() - dMainTot$scenario <- dMainTot$identifier p1 <- p1 + geom_line( data = dMainTot, diff --git a/README.md b/README.md index 61fa2b1..d3d8a19 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Comparison of multi-model runs -R package **mip**, version **0.151.0** +R package **mip**, version **0.151.1** [![CRAN status](https://www.r-pkg.org/badges/version/mip)](https://cran.r-project.org/package=mip) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1158586.svg)](https://doi.org/10.5281/zenodo.1158586) [![R build status](https://github.com/pik-piam/mip/workflows/check/badge.svg)](https://github.com/pik-piam/mip/actions) [![codecov](https://codecov.io/gh/pik-piam/mip/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mip) [![r-universe](https://pik-piam.r-universe.dev/badges/mip)](https://pik-piam.r-universe.dev/builds) @@ -47,7 +47,7 @@ In case of questions / problems please contact David Klein , R package version 0.151.0, . +Klein D, Dietrich J, Baumstark L, Humpenoeder F, Stevanovic M, Wirth S, Führlich P, Richters O, Rüter T (2024). _mip: Comparison of multi-model runs_. doi:10.5281/zenodo.1158586 , R package version 0.151.1, . A BibTeX entry for LaTeX users is @@ -56,7 +56,7 @@ A BibTeX entry for LaTeX users is title = {mip: Comparison of multi-model runs}, author = {David Klein and Jan Philipp Dietrich and Lavinia Baumstark and Florian Humpenoeder and Miodrag Stevanovic and Stephen Wirth and Pascal Führlich and Oliver Richters and Tonn Rüter}, year = {2024}, - note = {R package version 0.151.0}, + note = {R package version 0.151.1}, url = {https://github.com/pik-piam/mip}, doi = {10.5281/zenodo.1158586}, }