diff --git a/.buildlibrary b/.buildlibrary index 7dbbbc50..40f1b541 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '218283264' +ValidationKey: '218439650' 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 153ce36c..ea2c637b 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: 'remind2: The REMIND R package (2nd generation)' -version: 1.114.6 -date-released: '2023-08-15' +version: 1.115.0 +date-released: '2023-08-22' abstract: Contains the REMIND-specific routines for data and model output manipulation. authors: - family-names: Rodrigues diff --git a/DESCRIPTION b/DESCRIPTION index 818d7c87..086fb94d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: remind2 Title: The REMIND R package (2nd generation) -Version: 1.114.6 -Date: 2023-08-15 +Version: 1.115.0 +Date: 2023-08-22 Authors@R: c( person("Renato", "Rodrigues", , "renato.rodrigues@pik-potsdam.de", role = c("aut", "cre")), person("Lavinia", "Baumstark", role = "aut"), diff --git a/README.md b/README.md index 3cf722ba..49d33fdf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # The REMIND R package (2nd generation) -R package **remind2**, version **1.114.6** +R package **remind2**, version **1.115.0** [![CRAN status](https://www.r-pkg.org/badges/version/remind2)](https://cran.r-project.org/package=remind2) [![R build status](https://github.com/pik-piam/remind2/workflows/check/badge.svg)](https://github.com/pik-piam/remind2/actions) [![codecov](https://codecov.io/gh/pik-piam/remind2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/remind2) [![r-universe](https://pik-piam.r-universe.dev/badges/remind2)](https://pik-piam.r-universe.dev/builds) @@ -49,7 +49,7 @@ In case of questions / problems please contact Renato Rodrigues . +Rodrigues R, Baumstark L, Benke F, Dietrich J, Dirnaichner A, Führlich P, Giannousakis A, Hasse R, Hilaire J, Klein D, Koch J, Kowalczyk K, Levesque A, Malik A, Merfort A, Merfort L, Morena-Leiva S, Pehl M, Pietzcker R, Rauner S, Richters O, Rottoli M, Schötz C, Schreyer F, Siala K, Sörgel B, Spahr M, Strefler J, Verpoort P (2023). _remind2: The REMIND R package (2nd generation)_. R package version 1.115.0, . A BibTeX entry for LaTeX users is @@ -58,7 +58,7 @@ A BibTeX entry for LaTeX users is title = {remind2: The REMIND R package (2nd generation)}, author = {Renato Rodrigues and Lavinia Baumstark and Falk Benke and Jan Philipp Dietrich and Alois Dirnaichner and Pascal Führlich and Anastasis Giannousakis and Robin Hasse and Jérome Hilaire and David Klein and Johannes Koch and Katarzyna Kowalczyk and Antoine Levesque and Aman Malik and Anne Merfort and Leon Merfort and Simón Morena-Leiva and Michaja Pehl and Robert Pietzcker and Sebastian Rauner and Oliver Richters and Marianna Rottoli and Christof Schötz and Felix Schreyer and Kais Siala and Björn Sörgel and Mike Spahr and Jessica Strefler and Philipp Verpoort}, year = {2023}, - note = {R package version 1.114.6}, + note = {R package version 1.115.0}, url = {https://github.com/pik-piam/remind2}, } ``` diff --git a/inst/markdown/compareScenarios2/cs2_06_energy_services.Rmd b/inst/markdown/compareScenarios2/cs2_06_energy_services.Rmd index 5ed2a66e..5e8a0d4e 100644 --- a/inst/markdown/compareScenarios2/cs2_06_energy_services.Rmd +++ b/inst/markdown/compareScenarios2/cs2_06_energy_services.Rmd @@ -240,31 +240,50 @@ items <- c("Production|Industry|Steel|Primary", dPlot <- data %>% filter(variable %in% items) %>% - mutate(foo = shorten_legend(variable)) %>% - order.levels(foo = rev(shorten_legend(items))) + mutate(variable = shorten_legend(variable)) %>% + order.levels(variable = rev(shorten_legend(items)), + scenario = unique(c('historical', levels(data$scenario)))) # Show at max 5 scenario rows by 7 region column plots for (regions in bin_distribute(getRegs(dPlot), 7)) { - for (scenarios in bin_distribute(getScenarios(dPlot), 5)) { - suppressWarnings( + for (scenarios in bin_distribute(setdiff(getScenarios(dPlot), 'historical'), + 5)) { + suppressWarnings( p <- ggplot_bar_remind_vts( data = dPlot %>% filter(scenario %in% scenarios, region %in% regions), - mapping = aes(x = period, y = value, fill = foo), + mapping = aes(x = period, y = value, fill = variable), gaps = 0) + scale_fill_discrete(breaks = shorten_legend(items), name = attr(shorten_legend(items), "front")) + # fix y-axis across regions (columns) geom_blank( data = dPlot %>% - filter(scenario %in% scenarios, - region %in% regions) %>% + filter(scenario %in% scenarios, + region %in% regions) %>% group_by(region, period, scenario) %>% summarise(value = sum(value), .groups = "drop_last") %>% mutate(value = max(value)) %>% add_remind_timesteps_columns(), mapping = aes(x = xpos, y = value)) + + geom_step(data = dPlot %>% + filter(region %in% regions, + 'historical' == scenario) %>% + complete(nesting(model, region, variable, unit, period, + value), + scenario = scenarios) %>% + filter('historical' != scenario) %>% + group_by(model, scenario, region, unit, period) %>% + arrange(model, scenario, region, unit, period, + desc(variable)) %>% + mutate(value = cumsum(value)) %>% + ungroup(), + mapping = aes(x = period, y = value, colour = 'historic', + group = interaction(region, variable)), + direction = 'vh') + + scale_colour_manual(values = c('historic' = 'black'), + name = NULL) + facet_wrap(~ interaction(region, scenario, sep = " "), nrow = length(scenarios), scales = "free_y") + labs(x = NULL, y = dPlot %>% pull(unit) %>% unique()) + @@ -275,6 +294,31 @@ for (regions in bin_distribute(getRegs(dPlot), 7)) { cat("\n\n") } } + +p <- ggplot() + + geom_line(data = dPlot %>% + filter(2100 >= period) %>% + group_by(scenario, region, period) %>% + mutate(value = value / sum(value), + variable = paste(variable, 'Share')) %>% + ungroup(), + mapping = aes(x = period, y = value, colour = scenario, + linetype = variable)) + + scale_colour_manual( + values = c(gg_colour_hue(setdiff(levels(dPlot$scenario), 'historical')), + c('historical' = 'black')), + name = NULL) + + scale_linetype_discrete(name = NULL, + guide = guide_legend(nrow = 2)) + + scale_y_continuous(breaks = seq(0, 1, 0.2), + minor_breaks = seq(0.1, 0.9, 0.2)) + + facet_wrap(~ region) + + labs(x = NULL, y = NULL) + + theme_minimal() + + theme(legend.position = 'bottom') + +plot(p) +cat('\n\n') ``` ### Subsector per-Capita Production