diff --git a/.buildlibrary b/.buildlibrary index 1c88679..6b4ea01 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '4182653' +ValidationKey: '4296180' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' @@ -6,3 +6,5 @@ AcceptedNotes: ~ AutocreateReadme: yes allowLinterWarnings: yes enforceVersionUpdate: no +AutocreateCITATION: yes +skipCoverage: no diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index f6ea5d4..5e205ab 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -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} @@ -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" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 243f46a..3edf90a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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 @@ -25,4 +25,4 @@ repos: - id: readme-rmd-rendered - id: use-tidy-description ci: - autoupdate_schedule: quarterly + autoupdate_schedule: weekly diff --git a/CITATION.cff b/CITATION.cff index a38c779..bc99e04 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: '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 .' diff --git a/DESCRIPTION b/DESCRIPTION index 3dc1423..688b5fb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 @@ -26,4 +26,4 @@ Suggests: Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 diff --git a/R/calcAgGDP.R b/R/calcAgGDP.R index ccd4838..562b94d 100644 --- a/R/calcAgGDP.R +++ b/R/calcAgGDP.R @@ -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" diff --git a/R/calcValidPopulation.R b/R/calcValidPopulation.R index 3d4878c..7bcf16d 100644 --- a/R/calcValidPopulation.R +++ b/R/calcValidPopulation.R @@ -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) diff --git a/R/convertTutorialWDI.R b/R/convertTutorialWDI.R index e05123d..1154cbb 100644 --- a/R/convertTutorialWDI.R +++ b/R/convertTutorialWDI.R @@ -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) } diff --git a/R/downloadTutorialWDI.R b/R/downloadTutorialWDI.R index bff3baf..30d1c7d 100644 --- a/R/downloadTutorialWDI.R +++ b/R/downloadTutorialWDI.R @@ -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") @@ -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)) } diff --git a/R/fullTUTORIAL.R b/R/fullTUTORIAL.R index b43e185..e897219 100644 --- a/R/fullTUTORIAL.R +++ b/R/fullTUTORIAL.R @@ -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"), diff --git a/R/fullTUTORIALVALIDATION.R b/R/fullTUTORIALVALIDATION.R index cf96c10..184edc2 100644 --- a/R/fullTUTORIALVALIDATION.R +++ b/R/fullTUTORIALVALIDATION.R @@ -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") diff --git a/R/fullValidation.R b/R/fullValidation.R index 679c407..0cceba5 100644 --- a/R/fullValidation.R +++ b/R/fullValidation.R @@ -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") diff --git a/R/readTutorialWDI.R b/R/readTutorialWDI.R index 85c7e95..468da03 100644 --- a/R/readTutorialWDI.R +++ b/R/readTutorialWDI.R @@ -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") diff --git a/R/spatialHeader.R b/R/spatialHeader.R index c1abb50..0c5c3fb 100644 --- a/R/spatialHeader.R +++ b/R/spatialHeader.R @@ -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") diff --git a/README.md b/README.md index b395537..d4170ff 100644 --- a/README.md +++ b/README.md @@ -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 @@ -40,15 +40,16 @@ In case of questions / problems please contact David Meng-Chuen Chen