diff --git a/.buildlibrary b/.buildlibrary index 15819f5..b634c00 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '178524' +ValidationKey: '198360' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 230bcac..3acf3de 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: 'piamPlotComparison: Create comparison plots for your model results' -version: 0.0.9 +version: 0.0.10 date-released: '2024-04-23' abstract: A frameworks to create comparison plots for your model results. authors: diff --git a/DESCRIPTION b/DESCRIPTION index b896c16..2bd5fab 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: piamPlotComparison Title: Create comparison plots for your model results -Version: 0.0.9 +Version: 0.0.10 Date: 2024-04-23 Authors@R: c( person("Falk", "Benke", , "benke@pik-potsdam.de", role = c("aut", "cre")), @@ -12,6 +12,7 @@ License: LGPL-3 URL: https://github.com/pik-piam/piamPlotComparison Imports: dplyr, + jsonlite, knitr, magclass, mip (>= 0.148.11), diff --git a/NAMESPACE b/NAMESPACE index 0c5e5c4..c012f5b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ export(calcTimeSeriesStats) export(compareScenarios) +export(getCs2Profiles) export(showStatsTable) importFrom(dplyr,"%>%") importFrom(dplyr,across) diff --git a/R/getCs2Profiles.R b/R/getCs2Profiles.R new file mode 100644 index 0000000..86545f2 --- /dev/null +++ b/R/getCs2Profiles.R @@ -0,0 +1,24 @@ +#' Get the List of cs2 Profiles +#' +#' A list of arguments to \code{\link{compareScenarios}} is called a (cs2-) +#' profile. This function loads a list of such profiles from a file. The default +#' argument is set such that the default profiles file of REMIND is loaded. +#' +#' @param path \code{character(1)}. Path to the profiles file. +#' @return A named list of profiles. The names are the names of the respective +#' profile. Each profile is a named list. Those names correspond to arguments +#' of \code{\link{compareScenarios}}. +#' @author Christof Schoetz +#' @examples +#' \dontrun{ +#' profiles <- getCs2Profiles() # load from default location +#' profiles <- getCs2Profiles(path = "path/to/profiles.json") +#' } +#' @export +getCs2Profiles <- function(path = "./scripts/cs2/profiles.json") { + path <- normalizePath(path, mustWork = TRUE) + profiles <- jsonlite::read_json(path, simplifyVector = FALSE) + # Remove entries starting with "_". They are treated as comments. + profiles <- profiles[!startsWith(names(profiles), "_")] + return(profiles) +} diff --git a/README.md b/README.md index c32007c..1a0cca4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Create comparison plots for your model results -R package **piamPlotComparison**, version **0.0.9** +R package **piamPlotComparison**, version **0.0.10** [![CRAN status](https://www.r-pkg.org/badges/version/piamPlotComparison)](https://cran.r-project.org/package=piamPlotComparison) [![R build status](https://github.com/pik-piam/piamPlotComparison/workflows/check/badge.svg)](https://github.com/pik-piam/piamPlotComparison/actions) [![codecov](https://codecov.io/gh/pik-piam/piamPlotComparison/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/piamPlotComparison) [![r-universe](https://pik-piam.r-universe.dev/badges/piamPlotComparison)](https://pik-piam.r-universe.dev/builds) @@ -46,7 +46,7 @@ In case of questions / problems please contact Falk Benke To cite package **piamPlotComparison** in publications use: -Benke F, Schoetz C (2024). _piamPlotComparison: Create comparison plots for your model results_. R package version 0.0.9, . +Benke F, Schoetz C (2024). _piamPlotComparison: Create comparison plots for your model results_. R package version 0.0.10, . A BibTeX entry for LaTeX users is @@ -55,7 +55,7 @@ A BibTeX entry for LaTeX users is title = {piamPlotComparison: Create comparison plots for your model results}, author = {Falk Benke and Christof Schoetz}, year = {2024}, - note = {R package version 0.0.9}, + note = {R package version 0.0.10}, url = {https://github.com/pik-piam/piamPlotComparison}, } ``` diff --git a/inst/compareScenarios/cs_main.Rmd b/inst/compareScenarios/cs_main.Rmd index 9586817..9aa6a62 100644 --- a/inst/compareScenarios/cs_main.Rmd +++ b/inst/compareScenarios/cs_main.Rmd @@ -234,7 +234,7 @@ options(warn = 1) options(mip.mainReg = params$mainReg) # nolint options(mip.yearsBarPlot = params$yearsBarPlot) # nolint -# Reference year for Kaya decomposition is params$yearRef or the first available year therafter. +# Reference year for Kaya decomposition is params$yearRef or the first available year thereafter. options(kaya.refYear = min(params$yearsScen[params$yearsScen >= params$yearRef])) # nolint # allow for duplicate chunk labels diff --git a/man/getCs2Profiles.Rd b/man/getCs2Profiles.Rd new file mode 100644 index 0000000..80e59fa --- /dev/null +++ b/man/getCs2Profiles.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getCs2Profiles.R +\name{getCs2Profiles} +\alias{getCs2Profiles} +\title{Get the List of cs2 Profiles} +\usage{ +getCs2Profiles(path = "./scripts/cs2/profiles.json") +} +\arguments{ +\item{path}{\code{character(1)}. Path to the profiles file.} +} +\value{ +A named list of profiles. The names are the names of the respective + profile. Each profile is a named list. Those names correspond to arguments + of \code{\link{compareScenarios}}. +} +\description{ +A list of arguments to \code{\link{compareScenarios}} is called a (cs2-) +profile. This function loads a list of such profiles from a file. The default +argument is set such that the default profiles file of REMIND is loaded. +} +\examples{ +\dontrun{ +profiles <- getCs2Profiles() # load from default location +profiles <- getCs2Profiles(path = "path/to/profiles.json") +} +} +\author{ +Christof Schoetz +}