Skip to content

Commit

Permalink
Merge pull request #4 from whitehacker/main
Browse files Browse the repository at this point in the history
Adjusted the where value in toolGetMapping()
  • Loading branch information
pfuehrlich-pik authored Oct 16, 2023
2 parents 552a5a1 + 37c300b commit 09b754a
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 44 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
^\.github$
^codecov\.yml$
^workflow$
^Makefile$
^.lintr$
^tests/.lintr$
^.*CITATION.cff$
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '552682'
ValidationKey: '4105710'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Run CI for R using https://eddelbuettel.github.io/r-ci/

name: lucode2-check
name: check

on:
push:
Expand All @@ -11,14 +11,14 @@ on:
env:
USE_BSPM: "true"
_R_CHECK_FORCE_SUGGESTS_: "false"
NO_BINARY_INSTALL_R_PACKAGES: 'c("madrat", "magclass", "citation", "gms", "goxygen")'
NO_BINARY_INSTALL_R_PACKAGES: 'c("madrat", "magclass", "citation", "gms", "goxygen", "GDPuc", "roxygen2")'

jobs:
lucode2-check:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Bootstrap
run: |
Expand All @@ -28,6 +28,7 @@ jobs:
curl -OLs https://eddelbuettel.github.io/r-ci/run.sh
chmod 0755 run.sh
./run.sh bootstrap
rm -f bspm_*.tar.gz
- name: Enable r-universe repo, modify bspm integration
run: |
Expand All @@ -48,19 +49,45 @@ jobs:
pkgs <- c(bspm::install_sys(pkgs[!pkgs %%in%% noBinaryInstallRPackages]),
pkgs[pkgs %%in%% noBinaryInstallRPackages])
}
type <- "source"
})
trace(utils::install.packages, expr, print = FALSE)
})
' "$NO_BINARY_INSTALL_R_PACKAGES" | sudo tee --append /etc/R/Rprofile.site >/dev/null
cat /etc/R/Rprofile.site
- uses: r-lib/actions/setup-pandoc@v1
- name: Set up Pandoc
uses: r-lib/actions/setup-pandoc@v2

- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Cache R libraries
if: ${{ !env.ACT }} # skip when running locally via nektos/act
uses: pat-s/always-upload-cache@v3
with:
path: /usr/local/lib/R/
key: 3-${{ runner.os }}-usr-local-lib-R-${{ hashFiles('DESCRIPTION') }}
restore-keys: |
3-${{ runner.os }}-usr-local-lib-R-
- name: Restore R library permissions
run: |
sudo chmod 2777 /usr/local/lib/R /usr/local/lib/R/site-library
- name: Install dependencies
run: |
./run.sh install_aptget libhdf5-dev
./run.sh install_aptget libhdf5-dev libharfbuzz-dev libfribidi-dev
./run.sh install_all
./run.sh install_r lucode2 covr
./run.sh install_r_binary covr rstudioapi
./run.sh install_r lucode2
- name: Install python dependencies if applicable
run: |
[ -f requirements.txt ] && python -m pip install --upgrade pip wheel || true
[ -f requirements.txt ] && pip install -r requirements.txt || true
- name: Remove bspm integration # to get rid of error when running install.packages
run: |
Expand Down
2 changes: 2 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
linters: lucode2::lintrRules()
encoding: "UTF-8"
22 changes: 19 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
# testthat snapshots are machine-generated regression tests that
# have to be preserved exactly as they are
exclude: '^tests/testthat/_snaps/.*$'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.4.0
hooks:
- id: check-case-conflict
- id: check-json
- id: check-yaml
- id: check-merge-conflict
- id: check-yaml
- id: fix-byte-order-marker
- id: end-of-file-fixer
- id: check-added-large-files
args: ['--maxkb=100']
- id: mixed-line-ending

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.2.9013
hooks:
- id: parsable-R
- id: deps-in-desc
args: [--allow_private_imports]
- id: no-browser-statement
- id: no-debug-statement
- id: readme-rmd-rendered
- id: use-tidy-description
ci:
autoupdate_schedule: quarterly
10 changes: 0 additions & 10 deletions .zenodo.json

This file was deleted.

15 changes: 15 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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.10
date-released: '2023-07-13'
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
.'
authors:
- family-names: Chen
given-names: David Meng-Chuen
email: [email protected]
license: GPL-3.0

36 changes: 19 additions & 17 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
Package: mrtutorial
Type: Package
Package: mrtutorial
Title: Tutorial Package For Madrat Package Library
Date: 2022-03-07
Version: 0.2.9
Version: 0.2.10
Date: 2023-07-13
Authors@R:
person("David Meng-Chuen", "Chen", email = "[email protected]", role = c("aut","cre"))
Description: 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 .
person("David Meng-Chuen", "Chen", , "[email protected]", role = c("aut", "cre"))
Description: 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 .
License: GPL-3
Depends:
R(>= 2.10.0),
magclass(>= 3.17),
madrat(>= 2.11.3)
License: GPL-3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
R (>= 2.10.0),
madrat (>= 2.11.3),
magclass (>= 3.17)
Imports:
WDI,
countrycode,
dplyr,
lucode2,
reshape2,
magpiesets,
dplyr,
tidyr,
rlang
reshape2,
rlang,
tidyr
Suggests:
covr
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
46 changes: 46 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.PHONY: help build check test lint lint-all format format-all install docs
.DEFAULT_GOAL = help

# extracts the help text and formats it nicely
HELP_PARSING = 'm <- readLines("Makefile");\
m <- grep("\#\#", m, value=TRUE);\
command <- sub("^([^ ]*) *\#\#(.*)", "\\1", m);\
help <- sub("^([^ ]*) *\#\#(.*)", "\\2", m);\
cat(sprintf("%-8s%s", command, help), sep="\n")'

help: ## Show this help.
@Rscript -e $(HELP_PARSING)

build: ## Build the package using lucode2::buildLibrary(). You can pass the
## updateType with 'make build u=3'
Rscript -e 'lucode2::buildLibrary(updateType = "$(u)")'

check: ## Build documentation and vignettes, run testthat tests,
## and check if code etiquette is followed using lucode2::check().
Rscript -e 'lucode2::check()'

test: ## Run testthat tests
Rscript -e 'devtools::test(show_report = TRUE)'

lint: ## Check if code etiquette is followed using lucode2::lint().
## Only checks files you changed.
Rscript -e 'lucode2::lint()'

lint-all: ## Check if code etiquette is followed using lucode2::lint().
## Checks all files.
Rscript -e 'lucode2::lint(".")'

format: ## Apply auto-formatting to changed files and lint afterwards.
Rscript -e 'lucode2::autoFormat()'

format-all: ## Apply auto-formatting to all files and lint afterwards.
Rscript -e 'lucode2::autoFormat(files=list.files("./R", full.names = TRUE, pattern = "\\.R"))'

install: ## Install the package locally via devtools::install() after
## generating NAMESPACE and docs (see docs target).
Rscript -e 'roxygen2::roxygenize(); devtools::install(upgrade = "never")'

docs: ## Generate the package documentation (man/*.Rd files) and
## NAMESPACE via roxygen2::roxygenize(), view the generated
## documentation with `?package::function`.
Rscript -e 'roxygen2::roxygenize()'
4 changes: 4 additions & 0 deletions R/mrtutorial-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The package documentation is defined in this file.
# You can get it via `library(<package>); ?<package>`.
#' @docType package
"_PACKAGE"
2 changes: 1 addition & 1 deletion R/spatialHeader.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spatialHeader <- function(mapping) {
regionscode <- regionscode(map)
reg <- as.character(map$RegionCode)
names(reg) <- as.character(map$CountryCode)
iso <- toolGetMapping(type = "cell", name = "CountryToCellMapping.csv")$iso
iso <- toolGetMapping(type = "cell", name = "CountryToCellMapping.csv", where = "mappingfolder")$iso
spatialHeader <- paste(reg[iso], seq_along(iso), sep = ".")
return(spatialHeader)
}
10 changes: 5 additions & 5 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.9**
R package **mrtutorial**, version **0.2.10**

[![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/ui#builds)
[![CRAN status](https://www.r-pkg.org/badges/version/mrtutorial)](https://cran.r-project.org/package=mrtutorial) [![R build status](https://github.com/whitehacker/mrtutorial/workflows/check/badge.svg)](https://github.com/whitehacker/mrtutorial/actions) [![codecov](https://codecov.io/gh/whitehacker/mrtutorial/branch/master/graph/badge.svg)](https://app.codecov.io/gh/whitehacker/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 @@ -38,15 +38,15 @@ In case of questions / problems please contact David Meng-Chuen Chen <david.chen

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

Chen D (2022). _mrtutorial: Tutorial Package For Madrat Package Library_. R package version 0.2.9.
Chen D (2023). _mrtutorial: Tutorial Package For Madrat Package Library_. R package version 0.2.10.

A BibTeX entry for LaTeX users is

```latex
@Manual{,
title = {mrtutorial: Tutorial Package For Madrat Package Library},
author = {David Meng-Chuen Chen},
year = {2022},
note = {R package version 0.2.9},
year = {2023},
note = {R package version 0.2.10},
}
```
14 changes: 14 additions & 0 deletions man/mrtutorial-package.Rd

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

2 changes: 2 additions & 0 deletions tests/.lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
linters: lucode2::lintrRules(allowUndesirable = TRUE)
encoding: "UTF-8"

0 comments on commit 09b754a

Please sign in to comment.