Skip to content

Commit

Permalink
Merge pull request #45 from DavidhoPIK/master
Browse files Browse the repository at this point in the history
comply with new convention to have column names "region", "country", "superregion" in regionmappings
  • Loading branch information
DavidhoPIK committed May 23, 2024
2 parents f207a73 + db1702b commit 473cb4a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '29386880'
ValidationKey: '29412660'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package .* was built under R version'
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: 'mrmagpie: madrat based MAgPIE Input Data Library'
version: 1.48.0
date-released: '2024-05-13'
version: 1.48.1
date-released: '2024-05-17'
abstract: Provides functions for MAgPIE country and cellular input data generation.
authors:
- family-names: Karstens
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: mrmagpie
Title: madrat based MAgPIE Input Data Library
Version: 1.48.0
Date: 2024-05-13
Version: 1.48.1
Date: 2024-05-17
Authors@R: c(
person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")),
person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = "aut"),
Expand Down
11 changes: 7 additions & 4 deletions R/toolApplyRegionNames.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ toolApplyRegionNames <- function(cdata, regionscode) {

# Get countries from magpie object and extend mapping
isocountries <- getItems(cdata, dim = 1.3, full = TRUE)
isoMap <- data.frame(CountryCode = isocountries)
map <- base::merge(isoMap, map, by = "CountryCode",
isoMap <- data.frame(country = isocountries)
# rename column names from old to new convention, if necessary
if ("CountryCode" %in% names(map)) names(map)[names(map) == "CountryCode"] <- "country"
if ("RegionCode" %in% names(map)) names(map)[names(map) == "RegionCode"] <- "region"
map <- base::merge(isoMap, map, by = "country",
all.x = TRUE, sort = FALSE, no.dups = TRUE)
# correct cell order
map <- map[match(isocountries, map$CountryCode), ]
map <- map[match(isocountries, map$country), ]

# Add regional information to magpie object
getItems(cdata, dim = 1, raw = TRUE) <- paste(gsub(".*\\.", "", getItems(cdata, dim = 1)),
map$RegionCode,
map$region,
as.character(seq_along(isocountries)),
sep = ".")
getSets(cdata, fulldim = FALSE)[1] <- "country.region.cell"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# madrat based MAgPIE Input Data Library

R package **mrmagpie**, version **1.48.0**
R package **mrmagpie**, version **1.48.1**

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

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Kristine Karstens <karstens@pik-p

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

Karstens K, Dietrich J, Chen D, Windisch M, Alves M, Beier F, Köberle A, v. Jeetze P, Mishra A, Humpenoeder F, Sauer P (2024). _mrmagpie: madrat based MAgPIE Input Data Library_. doi:10.5281/zenodo.4319612 <https://doi.org/10.5281/zenodo.4319612>, R package version 1.48.0, <https://github.com/pik-piam/mrmagpie>.
Karstens K, Dietrich J, Chen D, Windisch M, Alves M, Beier F, Köberle A, v. Jeetze P, Mishra A, Humpenoeder F, Sauer P (2024). _mrmagpie: madrat based MAgPIE Input Data Library_. doi: 10.5281/zenodo.4319612 (URL: https://doi.org/10.5281/zenodo.4319612), R package version 1.48.1, <URL: https://github.com/pik-piam/mrmagpie>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,8 +48,8 @@ A BibTeX entry for LaTeX users is
title = {mrmagpie: madrat based MAgPIE Input Data Library},
author = {Kristine Karstens and Jan Philipp Dietrich and David Chen and Michael Windisch and Marcos Alves and Felicitas Beier and Alexandre Köberle and Patrick {v. Jeetze} and Abhijeet Mishra and Florian Humpenoeder and Pascal Sauer},
year = {2024},
note = {R package version 1.48.0},
url = {https://github.com/pik-piam/mrmagpie},
note = {R package version 1.48.1},
doi = {10.5281/zenodo.4319612},
url = {https://github.com/pik-piam/mrmagpie},
}
```

0 comments on commit 473cb4a

Please sign in to comment.