Skip to content

Commit

Permalink
Update GiHub workflows and README
Browse files Browse the repository at this point in the history
  • Loading branch information
simisc committed Mar 21, 2023
1 parent ebdd88b commit d81379b
Show file tree
Hide file tree
Showing 6 changed files with 770 additions and 79 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
Expand All @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
Expand All @@ -29,30 +29,21 @@ jobs:
R_KEEP_PKG_SOURCE: yes

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

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: rcmdcheck
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v1

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
upload-snapshots: true
60 changes: 31 additions & 29 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- main
- master
branches: [main, master]
pull_request:
branches:
- main
- master
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: macOS-latest
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

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

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Query dependencies
- name: Test coverage
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install dependencies
- name: Show testthat output
if: always()
run: |
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("covr")
shell: Rscript {0}
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: whozr
Type: Package
Title: Convert Raw Anthrops to WHO Z-Scores
Version: 1.1.2
Version: 1.1.3
Authors@R: person("Simon", "Schoenbuchner",
email = "[email protected]",
role = c("aut", "cre"),
Expand All @@ -14,7 +14,7 @@ Depends: R (>= 2.10)
License: GPL-3 + file LICENSE
Encoding: UTF-8
LazyData: true
Imports: dplyr (>= 1.0.9), tibble (>= 3.1.8), stats, utils, rlang
Imports: dplyr (>= 1.0.9), tibble (>= 3.1.8), stats, rlang
RoxygenNote: 7.2.1
Suggests:
Suggests:
testthat
37 changes: 21 additions & 16 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ output: github_document

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```

# whozr

[![R build status](https://github.com/simisc/whozr/workflows/R-CMD-check/badge.svg)](https://github.com/simisc/whozr/actions)

<!-- badges: start -->
[![check-standard](https://github.com/simisc/whozr/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/simisc/whozr/actions/workflows/check-standard.yaml)
[![DOI](https://zenodo.org/badge/113995327.svg)](https://zenodo.org/badge/latestdoi/113995327)
[![Licence](https://img.shields.io/github/license/simisc/whozr)](https://github.com/simisc/whozr/blob/master/LICENSE)
[![Lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
[![codecov](https://codecov.io/gh/simisc/whozr/branch/master/graph/badge.svg?token=OTFYOOXEVC)](https://codecov.io/gh/simisc/whozr)
<!-- badges: end -->

Convert raw anthropometric measurement (weight, height, length, BMI, MUAC, head circumeference, tricep skinfold and subscapular skinfold) to z-scores, using the WHO growth standards (0-5 years) and/or references (5-19 years).

Expand All @@ -29,27 +31,30 @@ Also allows the 'reverse' calculation of original anthropometry measures from z-
You can install whozr from github with:

```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("simisc/whozr")
# install.packages("remotes")
remotes::install_github("simisc/whozr")
```

## Example

```{r message=FALSE, warning=FALSE}
library(dplyr) # tibble(), %>%, mutate()
library(dplyr) # tibble(), mutate()
library(knitr) # kable()
library(whozr) # zwa(), zla(), zwl()
```


```{r}
tibble(sex = c("F", "M", "M", "F"),
age_days = c(120, 310, 370, 460),
weight_kg = c(5.98, 8.09, 8.40, 8.46),
length_cm = c(60.2, 70.7, 72.6, 74.9)) %>%
mutate(waz = zwa(weight_kg, age_days, sex),
laz = zla(length_cm, age_days, sex),
wlz = zwl(weight_kg, length_cm, sex)) %>%
tibble(
sex = c("F", "M", "M", "F"),
age_days = c(120, 310, 370, 460),
weight_kg = c(5.98, 8.09, 8.40, 8.46),
length_cm = c(60.2, 70.7, 72.6, 74.9)
) |>
mutate(
waz = zwa(weight_kg, age_days, sex),
laz = zla(length_cm, age_days, sex),
wlz = zwl(weight_kg, length_cm, sex)
) |>
kable(digits = 3)
```

Loading

0 comments on commit d81379b

Please sign in to comment.