Skip to content

Commit

Permalink
Merge pull request #10 from fbenke-pik/master
Browse files Browse the repository at this point in the history
update vignette for compareScenarios
  • Loading branch information
fbenke-pik authored Apr 29, 2024
2 parents 58ae8b2 + de00b38 commit 4c67cf2
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 558 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '218218'
ValidationKey: '238104'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exclude: '^tests/testthat/_snaps/.*$'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
hooks:
- id: check-case-conflict
- id: check-json
Expand All @@ -15,7 +15,7 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.0
rev: 7910e0323d7213f34275a7a562b9ef0fde8ce1b9 # frozen: v0.4.2
hooks:
- id: parsable-R
- id: deps-in-desc
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: 'piamPlotComparison: Create comparison plots for your model results'
version: 0.0.11
date-released: '2024-04-25'
version: 0.0.12
date-released: '2024-04-29'
abstract: A frameworks to create comparison plots for your model results.
authors:
- family-names: Benke
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: piamPlotComparison
Title: Create comparison plots for your model results
Version: 0.0.11
Date: 2024-04-25
Version: 0.0.12
Date: 2024-04-29
Authors@R: c(
person("Falk", "Benke", , "[email protected]", role = c("aut", "cre")),
person("Christof", "Schoetz", role = "aut")
Expand Down
14 changes: 9 additions & 5 deletions R/compareScenarios.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#' choose Rmd as output format and obtain a copy of the *.Rmd-files.
#'
#' @param projectLibrary \code{NULL} or \code{character(n)}. Default: \code{NULL}.
#' An R library containing Rmd files that could be included. You can further filter
#' the sections to be rendered using the \code{sections} YAML parameter.
#' Expects the Rmd files must be placed in a folder \code{inst/compareScenarios}.
#' Files must have the format \code{cs_[NUMBER]_*.Rmd} to be considered.
#' An R reporting library containing Rmd files to be included.
#' You can further filter the sections to be rendered using the \code{sections} YAML parameter.
#' The Rmd files must be placed in a folder \code{inst/compareScenarios}.
#' Files must have the format \code{cs_NN_XXXX.Rmd} to be considered.
#' If the folder contains a file \code{preprocessing.Rmd}, it will be executed
#' before rendering the sections.
#' @param mifScen \code{character(n)}, optionally named. Paths to scenario mifs.
Expand Down Expand Up @@ -95,11 +95,13 @@
#' \dontrun{
#' # Simple use. Creates PDF:
#' compareScenarios(
#' projectLibrary = "mylib",
#' mifScen = c("path/to/Base.mif", "path/to/NDC.mif"),
#' mifHist = "path/to/historical.mif",
#' outputFile = "CompareScenariosExample")
#' # More complex use. Creates folder with Rmds:
#' compareScenarios(
#' projectLibrary = "mylib",
#' mifScen = c(ScenarioName1 = "path/to/scen1.mif", ScenarioName2 = "path/to/scen2.mif"),
#' mifHist = "path/to/historical.mif",
#' cfgScen = c("path/to/scen1/config.RData", "path/to/scen2/config.RData"),
Expand All @@ -111,6 +113,7 @@
#' userSectionPath = "path/to/myPlots.Rmd")
#' # Use in development. Load data into global environment:
#' compareScenarios(
#' projectLibrary = "mylib",
#' mifScen = c("path/to/scen1.mif", "path/to/scen2.mif"),
#' mifHist = "path/to/historical.mif",
#' outputFile = format(Sys.time(), "cs2_load_%Y%m%d-%H%M%S"),
Expand All @@ -119,8 +122,9 @@
#' }
#' @export
compareScenarios <- function(
mifScen, mifHist,
projectLibrary = NULL,
mifScen,
mifHist,
outputDir = getwd(),
outputFile = "CompareScenarios",
outputFormat = "PDF",
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Create comparison plots for your model results

R package **piamPlotComparison**, version **0.0.11**
R package **piamPlotComparison**, version **0.0.12**

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

Expand Down Expand Up @@ -46,7 +46,7 @@ In case of questions / problems please contact Falk Benke <[email protected]>

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.11, <https://github.com/pik-piam/piamPlotComparison>.
Benke F, Schoetz C (2024). _piamPlotComparison: Create comparison plots for your model results_. R package version 0.0.12, <https://github.com/pik-piam/piamPlotComparison>.

A BibTeX entry for LaTeX users is

Expand All @@ -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.11},
note = {R package version 0.0.12},
url = {https://github.com/pik-piam/piamPlotComparison},
}
```
3 changes: 2 additions & 1 deletion inst/compareScenarios/cs_main.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ suppressMessages(library(kableExtra))
library(quitte)
library(mip)
library(piamutils)
library(piamPlotComparison)
```


Expand Down Expand Up @@ -282,7 +283,7 @@ data <- as.quitte(data)
```{r remove objects not to be used anymore}
varNames <- c(
"availableSections", "cfgTopLevel", "dataScenNested", "env", "envToolsRstudio",
"availableSections", "dataScenNested", "env", "envToolsRstudio",
"fn", "insertExprAtStartOfFun", "lightenColor", "loadCfg", "matches",
"oldRsSetNotebookGraphicsOption")
for (vn in varNames) if (exists(vn)) rm(list = vn)
Expand Down
21 changes: 12 additions & 9 deletions man/compareScenarios.Rd

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

50 changes: 17 additions & 33 deletions vignettes/compareScenarios.R
Original file line number Diff line number Diff line change
@@ -1,58 +1,42 @@
## ----include = FALSE---------------------------------------------------------------------------------------------------------------
## ----include = FALSE------------------------------------------------------------------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval = FALSE
)

## ----------------------------------------------------------------------------------------------------------------------------------
# library(remind2)
# compareScenarios2(
## -------------------------------------------------------------------------------------------------------------------------------------
# library(piamPlotComparison)
# compareScenarios(
# projectLibrary = "myProjectLibrary",
# mifScen = c("path/to/Base.mif", "path/to/NDC.mif"),
# mifHist = "path/to/historical.mif",
# outputFile = "CompareScenarios2Example")
# outputFile = "CompareScenariosExample")

## ----------------------------------------------------------------------------------------------------------------------------------
# library(remind2)
# compareScenarios2(
## -------------------------------------------------------------------------------------------------------------------------------------
# library(piamPlotComparison)
# compareScenarios(
# projectLibrary = "myProjectLib",
# mifScen = c("path/to/scen1.mif", "path/to/scen2.mif", "path/to/scen3.mif"), # TODO.
# mifHist = "path/to/historical.mif", # TODO.
# outputDir = "path/to/where/rmds/should/be/copied/to", # TODO.
# outputFormat = "Rmd",
# # Add current time as output name to not overwrite other things:
# outputFile = format(Sys.time(), "CompScen2-%Y%m%d-%H%M%S"))

## ----prepare mark------------------------------------------------------------------------------------------------------------------
## ----prepare mark---------------------------------------------------------------------------------------------------------------------
# # CLICK "RUN ALL CHUNKS ABOVE" HERE TO PREPARE THE ENVIRONMENT

## ----------------------------------------------------------------------------------------------------------------------------------
# library(remind2)
# loadModeltest()
# varList <- variablesAsList(data, entry = "INFO")
# View(varList) # in RStudio

## ----------------------------------------------------------------------------------------------------------------------------------
# loadCs2Data(
# c("path/to/scen1.mif", "path/to/scen2.mif"), # TODO.
# "path/to/historical.mif") # TODO.

## ----------------------------------------------------------------------------------------------------------------------------------
# compareScenarios2(
# mifScen = c("path/to/scen1.mif", "path/to/scen2.mif"), # TODO.
# mifHist = "path/to/historical.mif", # TODO.
# outputFile = format(Sys.time(), "cs2-%Y%m%d-%H%M%S"),
# sections = NN) # TODO: Replace NN by the number of the section you changed
# # (or by "all" to build the whole compare scenarios file, which will take a while).

## ----------------------------------------------------------------------------------------------------------------------------------
# compareScenarios2(
## -------------------------------------------------------------------------------------------------------------------------------------
# compareScenarios(
# projectLibrary = "myProjectLib",
# mifScen = c(newName1 = "path/to/scen1.mif", newName2 = "path/to/scen2.mif"),
# ...)

## ----------------------------------------------------------------------------------------------------------------------------------
# compareScenarios2(
## -------------------------------------------------------------------------------------------------------------------------------------
# compareScenarios(
# projectLibrary = "myProjectLib",
# mifScen = c("path/to/scen1.mif", "path/to/scen2.mif"),
# cfgScen = c("path/to/scen1/config.RData", "path/to/scen2/config.RData"),
# cfgDefault = "path/to/default.cfg",
# ...)

Loading

0 comments on commit 4c67cf2

Please sign in to comment.