Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
ValidationKey: '4182653'
ValidationKey: '4296180'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
AcceptedNotes: ~
AutocreateReadme: yes
allowLinterWarnings: yes
enforceVersionUpdate: no
AutocreateCITATION: yes
skipCoverage: no
30 changes: 14 additions & 16 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,24 @@ jobs:
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::lucode2
any::covr
any::madrat
any::magclass
any::citation
any::gms
any::goxygen
any::GDPuc
lucode2
covr
madrat
magclass
citation
gms
goxygen
GDPuc
# piam packages also available on CRAN (madrat, magclass, citation,
# gms, goxygen, GDPuc) will usually have an outdated binary version
# available; by using extra-packages we get the newest version

- uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Install python dependencies if applicable
- name: Run pre-commit checks
shell: bash
run: |
[ -f requirements.txt ] && python -m pip install --upgrade pip wheel || true
[ -f requirements.txt ] && pip install -r requirements.txt || true
python -m pip install pre-commit
python -m pip freeze --local
pre-commit run --show-diff-on-failure --color=always --all-files

- name: Verify validation key
shell: Rscript {0}
Expand All @@ -63,6 +61,6 @@ jobs:
shell: Rscript {0}
run: |
nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps"))
if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE)
if(length(nonDummyTests) > 0 && !lucode2:::loadBuildLibraryConfig()[["skipCoverage"]]) covr::codecov(quiet = FALSE)
env:
NOT_CRAN: "true"
6 changes: 3 additions & 3 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: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.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: 3b70240796cdccbe1474b0176560281aaded97e6 # frozen: v0.4.3.9003
hooks:
- id: parsable-R
- id: deps-in-desc
Expand All @@ -25,4 +25,4 @@ repos:
- id: readme-rmd-rendered
- id: use-tidy-description
ci:
autoupdate_schedule: quarterly
autoupdate_schedule: weekly
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: 'mrtutorial: Tutorial Package For Madrat Package Library'
version: 0.2.11
date-released: '2024-04-10'
version: 0.2.12
date-released: '2025-06-26'
abstract: 'Example package of mr- world libraries, in conjunction with MAgPIE MADRat
tutorial. For more information please see: https://github.com/magpiemodel/tutorials/tree/master/madrat
.'
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: mrtutorial
Title: Tutorial Package For Madrat Package Library
Version: 0.2.11
Date: 2024-04-10
Version: 0.2.12
Date: 2025-06-26
Authors@R:
person("David Meng-Chuen", "Chen", , "david.chen@pik-potsdam.de", role = c("aut", "cre"))
Description: Example package of mr- world libraries, in conjunction with
Expand All @@ -26,4 +26,4 @@ Suggests:
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
2 changes: 1 addition & 1 deletion R/calcAgGDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ calcAgGDP <- function(){

ag_gdp <- readSource("TutorialWDI", subtype="NV.AGR.TOTL.CD")

x <- ag_gdp/gdp
x <- ag_gdp / gdp
x <- collapseNames(x)
getNames(x) <- "Ag_GDP_share"

Expand Down
12 changes: 6 additions & 6 deletions R/calcValidPopulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

calcValidPopulation <- function(datasource="WDI") {

if(datasource=="WDI"){

if (datasource == "WDI") {
out <- readSource("TutorialWDI", "SP.POP.TOTL")
} else {
stop("No datasource of the given name.")
}

} else { stop("No datasource of the given name.") }

getNames(out) <- "Population (million people)"
getSets(out,fulldim = FALSE)[3] <- "variable"
getNames(out) <- "Population (million people)"
getSets(out, fulldim = FALSE)[3] <- "variable"

out <- add_dimension(out, dim=3.1, add="scenario", nm = "historical")
out <- add_dimension(out, dim=3.2, add="model", nm = datasource)
Expand Down
29 changes: 13 additions & 16 deletions R/convertTutorialWDI.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,25 @@
#' @importFrom madrat toolCountryFill


convertTutorialWDI<-function(x, subtype){
convertTutorialWDI <- function(x, subtype) {

# change scale of absolute indicators, MAgPIE runs in Million scale for Pop and GDP drivers
if (subtype %in% c("NY.GDP.MKTP.CD",
if (subtype %in% c("NY.GDP.MKTP.CD",
"SP.POP.TOTL",
"NV.AGR.TOTL.CD")){

out <- x/1e6 } else

if (subtype == "SL.AGR.EMPL.ZS"){
# don't change for percentage of ag employment

out <- x } else{

stop("subtype does not exist in the dataset!")}
"NV.AGR.TOTL.CD")) {
out <- x/1e6
} else if (subtype == "SL.AGR.EMPL.ZS") {
# don't change for percentage of ag employment
out <- x
} else {
stop("subtype does not exist in the dataset!")
}

# toolCountryFill fills in missing countries - 249 required for aggregation
x <- toolCountryFill(out, fill = 0)

x<-toolCountryFill(out,fill = 0)

x[is.na(x)] <- 0 #remove NAs

#remove NAs
x[is.na(x)] <- 0

return(x)
}
14 changes: 7 additions & 7 deletions R/downloadTutorialWDI.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' Download WDI (World development indicators) data .rda file.
#'
#' @author David Chen
#' @seealso \code{\link{downloadSource}} \code{\link{WDI}}
#' @seealso \code{\link[madrat]{downloadSource}} \code{\link[WDI]{WDI}}
#' @examples
#'
#' \dontrun{ a <- downloadSource(type="TutorialWDI")
Expand All @@ -12,20 +12,20 @@
#' @importFrom WDI WDI WDIcache WDIsearch


downloadTutorialWDI<-function(){
downloadTutorialWDI <- function() {
indicator <- c("NY.GDP.MKTP.CD", # gdp PPP current US$
"SP.POP.TOTL", # Total population
"SL.AGR.EMPL.ZS", #Employment in agriculture as % of total employment
"SP.POP.TOTL", # Total population
"SL.AGR.EMPL.ZS", # Employment in agriculture as % of total employment
"NV.AGR.TOTL.CD") # Ag GDP current US$
wdi <- WDI(indicator = indicator,start= 1960, end = 2018)
save(wdi,file = paste("WDI","rda",sep="."))
wdi <- WDI(indicator = indicator, start = 1960, end = 2018)
save(wdi, file = paste("WDI", "rda", sep = "."))

return(list(url = "https://data.worldbank.org/indicator/",
doi = NULL,
title = "World Bank Development Indicators",
description = "GDP and Population indicators",
author = NULL,
license = NULL,
license = NULL,
unit = NULL))

}
2 changes: 1 addition & 1 deletion R/fullTUTORIAL.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @param extra extra text to insert
#' @author David M Chen
#' @seealso
#' \code{\link{readSource}}, \code{\link{getCalculations}}, \code{\link{calcOutput}}
#' \code{\link[madrat]{readSource}}, \code{\link[madrat]{getCalculations}}, \code{\link[madrat]{calcOutput}}
#' @examples
#' \dontrun{
#' retrieveData("tutorial", rev = numeric_version("12"),
Expand Down
2 changes: 1 addition & 1 deletion R/fullTUTORIALVALIDATION.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @param rev data revision which should be used as input (positive numeric).
#' @author Jan Philipp Dietrich, Kristine Karstens
#' @seealso
#' \code{\link{readSource}}, \code{\link{getCalculations}}, \code{\link{calcOutput}}
#' \code{\link[madrat]{readSource}}, \code{\link[madrat]{getCalculations}}, \code{\link[madrat]{calcOutput}}
#' @examples
#' \dontrun{
#' retrieveData("VALIDATION")
Expand Down
2 changes: 1 addition & 1 deletion R/fullValidation.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @param rev data revision which should be used as input (positive numeric).
#' @author Jan Philipp Dietrich, Kristine Karstens
#' @seealso
#' \code{\link{readSource}}, \code{\link{getCalculations}}, \code{\link{calcOutput}}
#' \code{\link[madrat]{readSource}}, \code{\link[madrat]{getCalculations}}, \code{\link[madrat]{calcOutput}}
#' @examples
#' \dontrun{
#' retrieveData("VALIDATION")
Expand Down
2 changes: 1 addition & 1 deletion R/readTutorialWDI.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' \item \code{NV.AGR.TOTL.CD}: Agricultural GDP (current international Dollar) }
#' @return magpie object of the WDI data
#' @author David Chen
#' @seealso \code{\link{readSource}} \code{\link{downloadTutorialWDI}}
#' @seealso \code{\link[madrat]{readSource}} \code{\link{downloadTutorialWDI}}
#' @examples
#'
#' \dontrun{ a <- readSource(type="WDI",subtype="SP.POP.TOTL")
Expand Down
2 changes: 1 addition & 1 deletion R/spatialHeader.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' data.frame.
#' @return A vector with 59199 elements
#' @author Jan Philipp Dietrich
#' @seealso \code{\link{regionscode}}
#' @seealso \code{\link[madrat]{regionscode}}
#' @examples
#' \dontrun{
#' spatialHeader("regionmappingMAgPIE.csv")
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Tutorial Package For Madrat Package Library

R package **mrtutorial**, version **0.2.11**
R package **mrtutorial**, version **0.2.12**

[![CRAN status](https://www.r-pkg.org/badges/version/mrtutorial)](https://cran.r-project.org/package=mrtutorial) [![R build status](https://github.com/caviddhen/mrtutorial/workflows/check/badge.svg)](https://github.com/caviddhen/mrtutorial/actions) [![codecov](https://codecov.io/gh/caviddhen/mrtutorial/branch/master/graph/badge.svg)](https://app.codecov.io/gh/caviddhen/mrtutorial) [![r-universe](https://pik-piam.r-universe.dev/badges/mrtutorial)](https://pik-piam.r-universe.dev/builds)
[![CRAN status](https://www.r-pkg.org/badges/version/mrtutorial)](https://cran.r-project.org/package=mrtutorial) [![R build status](https://github.com/pik-piam/mrtutorial/workflows/check/badge.svg)](https://github.com/pik-piam/mrtutorial/actions) [![codecov](https://codecov.io/gh/pik-piam/mrtutorial/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrtutorial) [![r-universe](https://pik-piam.r-universe.dev/badges/mrtutorial)](https://pik-piam.r-universe.dev/builds)

## Purpose and Functionality

Expand Down Expand Up @@ -40,15 +40,16 @@ In case of questions / problems please contact David Meng-Chuen Chen <david.chen

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

Chen D (2024). _mrtutorial: Tutorial Package For Madrat Package Library_. R package version 0.2.11.
Chen D (2025). "mrtutorial: Tutorial Package For Madrat Package Library." Version: 0.2.12.

A BibTeX entry for LaTeX users is

```latex
@Manual{,
@Misc{,
title = {mrtutorial: Tutorial Package For Madrat Package Library},
author = {David Meng-Chuen Chen},
year = {2024},
note = {R package version 0.2.11},
date = {2025-06-26},
year = {2025},
note = {Version: 0.2.12},
}
```
2 changes: 1 addition & 1 deletion man/downloadTutorialWDI.Rd

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

2 changes: 1 addition & 1 deletion man/fullTUTORIAL.Rd

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

2 changes: 1 addition & 1 deletion man/fullTUTORIALVALIDATION.Rd

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

2 changes: 1 addition & 1 deletion man/fullVALIDATION.Rd

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

2 changes: 1 addition & 1 deletion man/readTutorialWDI.Rd

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

2 changes: 1 addition & 1 deletion man/spatialHeader.Rd

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