mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 06:30:48 +01:00
- New sir_combine() to combine SIR results of multiple antimicrobials into one variable; antibiogram(), wisca() and the count/proportion functions now use the same engine (antibiogram() and wisca() output unchanged) - With multiple antimicrobials, count_*() and proportion_*() now follow the documented combination therapy rules: resistance() is the proportion of failing combinations, count_all() excludes isolates with an unknown combination result, and WT/NWT/NS/NI are handled correctly - where() is now decided at runtime instead of at installation, fixing antibiogram() and wisca() without tidyselect (e.g. CRAN binaries without dplyr) - Imports from data.table and cli moved to .onLoad(); data.table functions are only used while it is loaded; the like() example no longer unloads data.table, which crashed R - Static test that fails on code outside functions depending on suggested packages - New check-without-dplyr workflow: installs AMR with all suggested packages, removes dplyr (and tidyselect), then runs all unit tests and examples against the installed package - g.test() now returns the degrees of freedom as 'parameter', so they are printed - Fix R CMD check NOTEs (hidden .claude folder, lost braces in inherited g.test and ggplot_pca docs)
117 lines
5.8 KiB
YAML
117 lines
5.8 KiB
YAML
# ==================================================================== #
|
|
# TITLE: #
|
|
# AMR: An R Package for Working with Antimicrobial Resistance Data #
|
|
# #
|
|
# SOURCE CODE: #
|
|
# https://github.com/msberends/AMR #
|
|
# #
|
|
# PLEASE CITE THIS SOFTWARE AS: #
|
|
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
|
|
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
|
|
# Journal of Statistical Software, 104(3), 1-31. #
|
|
# https://doi.org/10.18637/jss.v104.i03 #
|
|
# #
|
|
# Developed at the University of Groningen and the University Medical #
|
|
# Center Groningen in the Netherlands, in collaboration with many #
|
|
# colleagues from around the world, see our website. #
|
|
# #
|
|
# This R package is free software; you can freely use and distribute #
|
|
# it for both personal and commercial purposes under the terms of the #
|
|
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
|
# the Free Software Foundation. #
|
|
# We created this package for both routine data analysis and academic #
|
|
# research and it was publicly released in the hope that it will be #
|
|
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
|
# #
|
|
# Visit our website for the full manual and a complete tutorial about #
|
|
# how to conduct AMR data analysis: https://amr-for-r.org #
|
|
# ==================================================================== #
|
|
|
|
# The AMR package must work fully without dplyr (and without tidyselect), as dplyr is only suggested.
|
|
# This workflow mimics a user who installs the CRAN binary (built on a machine with ALL suggested packages) but does not have dplyr: AMR is installed while dplyr and tidyselect are available, after which they and all packages depending on them are removed, and all unit tests and all examples are run against the installed package. R CMD check cannot detect these problems, as it reinstalls the package itself.
|
|
|
|
on:
|
|
pull_request:
|
|
# run in each PR in this repo
|
|
branches: '**'
|
|
push:
|
|
# only on main; pushing to a PR branch is already covered by pull_request above
|
|
branches: [main]
|
|
schedule:
|
|
# also run a schedule everyday at 2 AM
|
|
- cron: '0 2 * * *'
|
|
|
|
name: check-without-dplyr
|
|
|
|
jobs:
|
|
setup:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
steps:
|
|
- id: set-matrix
|
|
shell: bash
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
|
echo 'matrix={"config":[{"os":"ubuntu-latest","r":"release","unavailable":"dplyr tidyselect"},{"os":"ubuntu-latest","r":"release","unavailable":"dplyr"}]}' >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo 'matrix={"config":[{"os":"ubuntu-latest","r":"release","unavailable":"dplyr tidyselect"},{"os":"ubuntu-latest","r":"release","unavailable":"dplyr"},{"os":"ubuntu-latest","r":"oldrel-1","unavailable":"dplyr tidyselect"},{"os":"windows-latest","r":"release","unavailable":"dplyr tidyselect"}]}' >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
R-without-dplyr:
|
|
needs: setup
|
|
runs-on: ${{ matrix.config.os }}
|
|
|
|
name: ${{ matrix.config.os }} (R-${{ matrix.config.r }}) without ${{ matrix.config.unavailable }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
|
|
|
|
env:
|
|
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
|
UNAVAILABLE: ${{ matrix.config.unavailable }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: r-lib/actions/setup-r@v2
|
|
with:
|
|
r-version: ${{ matrix.config.r }}
|
|
# use RStudio Package Manager to quickly install packages
|
|
use-public-rspm: true
|
|
|
|
- uses: r-lib/actions/setup-r-dependencies@v2
|
|
with:
|
|
# all dependencies, including suggested packages such as dplyr and tidyselect
|
|
dependencies: '"all"'
|
|
extra-packages: any::testthat
|
|
|
|
- name: Install AMR while dplyr and tidyselect are available
|
|
shell: Rscript {0}
|
|
run: |
|
|
stopifnot(requireNamespace("dplyr", quietly = TRUE), requireNamespace("tidyselect", quietly = TRUE))
|
|
install.packages(".", repos = NULL, type = "source")
|
|
stopifnot(requireNamespace("AMR", quietly = TRUE))
|
|
|
|
- name: Remove ${{ matrix.config.unavailable }} and all packages depending on them
|
|
shell: Rscript {0}
|
|
run: |
|
|
remove <- strsplit(Sys.getenv("UNAVAILABLE"), " ", fixed = TRUE)[[1]]
|
|
ip <- utils::installed.packages()
|
|
rev <- tools::dependsOnPkgs(remove, dependencies = c("Depends", "Imports", "LinkingTo"), recursive = TRUE, installed = ip)
|
|
drop <- setdiff(unique(c(remove, rev)), "AMR")
|
|
stopifnot(!"testthat" %in% drop)
|
|
cat("Removing", length(drop), "packages:", paste(sort(drop), collapse = ", "), "\n")
|
|
for (i in which(ip[, "Package"] %in% drop)) {
|
|
utils::remove.packages(ip[i, "Package"], lib = ip[i, "LibPath"])
|
|
}
|
|
for (pkg in remove) {
|
|
if (requireNamespace(pkg, quietly = TRUE)) stop(pkg, " is still available")
|
|
}
|
|
stopifnot(requireNamespace("testthat", quietly = TRUE), requireNamespace("AMR", quietly = TRUE))
|
|
|
|
- name: Run all unit tests and examples against the installed package
|
|
shell: bash
|
|
run: Rscript .github/scripts/test_installed_without.R $UNAVAILABLE
|