Skip to content

Commit

Permalink
Merge pull request #91 from tonnrueter/master
Browse files Browse the repository at this point in the history
Fix empty canvas issues in plotPercentiles
  • Loading branch information
tonnrueter authored Mar 7, 2024
2 parents 9c44f0c + 0169313 commit 9c8e7c0
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '29421782'
ValidationKey: '29444544'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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.148.7
date-released: '2024-03-04'
version: 0.148.8
date-released: '2024-03-06'
abstract: Package contains generic functions to produce comparison plots of multi-model
runs.
authors:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: mip
Title: Comparison of multi-model runs
Version: 0.148.7
Date: 2024-03-04
Version: 0.148.8
Date: 2024-03-06
Authors@R: c(
person("David", "Klein", , "[email protected]", role = c("aut", "cre")),
person("Jan Philipp", "Dietrich", , "[email protected]", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ importFrom(stats,na.omit)
importFrom(stats,reshape)
importFrom(stats,runif)
importFrom(stringr,str_extract)
importFrom(tidyr,all_of)
importFrom(tidyr,crossing)
importFrom(tidyr,drop_na)
importFrom(tidyr,pivot_wider)
Expand Down
18 changes: 12 additions & 6 deletions R/plotPercentiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,31 @@
#' }
#' @section Example Plot:
#' \if{html}{\figure{plotPercentiles1.png}{Atmospheric CO2 concentrations for all scenarios available in the data}}
#' @importFrom dplyr filter mutate vars
#' @importFrom dplyr filter mutate vars select
#' @importFrom reshape2 melt
#' @importFrom stringr str_extract
#' @importFrom tidyr pivot_wider
#' @importFrom tidyr pivot_wider all_of
#' @importFrom ggplot2 ggplot geom_line geom_ribbon facet_wrap facet_grid theme ylab
#' @export
plotPercentiles <- function(df, scenarios = NULL, variables = NULL) {

# Dropped "model" from Necessary columns
necessaryCols <- c("scenario", "region", "variable", "unit", "period", "value")
# In the quitte data frame all percentiles are given as individual variables. Manipulate input data frame such that
# all percentiles of a given quantity are transformed to individual columns. Variable names in the quitte data frame
# follow the format "Any|Variable|5.0th Percentile". The regular expressions below divide the variable name into the
# prefix and the percentile specifier
# all percentiles of a given quantity are transformed to individual columns
data <- df %>%
# Drop NA values
as.quitte(na.rm = TRUE) %>%
# Only use necessary columns. The .data-prefix in col names was deprecated in tidyselect since v1.2.0.
select(all_of(necessaryCols)) %>%
# Variable names in the quitte data frame follow the format "Any|Variable|5.0th Percentile". The regular
# expressions below divide the variable name into the prefix and the percentile specifier
mutate(
"percentile" = stringr::str_extract(.data$variable, "[^\\|]+?$"),
"variable" = gsub("\\|[^\\|]+$", "", .data$variable)
) %>%
# Remove all non-percentile variables
filter(grepl(" Percentile$", .data$percentile)) %>%
# Pivot data such that percentiles are transformed to individual columns
pivot_wider(
names_from = "percentile",
values_from = "value"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Comparison of multi-model runs

R package **mip**, version **0.148.7**
R package **mip**, version **0.148.8**

[![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)

Expand Down Expand Up @@ -47,7 +47,7 @@ In case of questions / problems please contact David Klein <[email protected]

To cite package **mip** in publications use:

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 <https://doi.org/10.5281/zenodo.1158586>, R package version 0.148.7, <https://github.com/pik-piam/mip>.
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 (URL: https://doi.org/10.5281/zenodo.1158586), R package version 0.148.8, <URL: https://github.com/pik-piam/mip>.

A BibTeX entry for LaTeX users is

Expand All @@ -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.148.7},
note = {R package version 0.148.8},
doi = {10.5281/zenodo.1158586},
url = {https://github.com/pik-piam/mip},
}
Expand Down
1 change: 0 additions & 1 deletion man/mip-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c8e7c0

Please sign in to comment.