Compare commits

..

No commits in common. "c44ddf272fc6a9172796b1c43f536207efdd7bf3" and "0d67db4f3259723760943e4b84bab22983a51c4c" have entirely different histories.

28 changed files with 80 additions and 62 deletions

View File

@ -32,9 +32,6 @@ name: R-code-check-PR
jobs: jobs:
R-code-check-PR: R-code-check-PR:
# do not run if we are the authors - the other checks will already run
if: ${{ github.event.comment.author_association != 'MEMBER' && github.event.comment.author_association != 'OWNER' }}
runs-on: ${{ matrix.config.os }} runs-on: ${{ matrix.config.os }}
continue-on-error: ${{ matrix.config.allowfail }} continue-on-error: ${{ matrix.config.allowfail }}

View File

@ -131,11 +131,9 @@ jobs:
_R_CHECK_LENGTH_1_LOGIC2_: verbose _R_CHECK_LENGTH_1_LOGIC2_: verbose
# during 'R CMD check', R_LIBS_USER will be overwritten, so: # during 'R CMD check', R_LIBS_USER will be overwritten, so:
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }} R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }}
# this is a required value to run the unit tests:
R_RUN_TINYTEST: true R_RUN_TINYTEST: true
run: | run: |
cd .. cd ..
ls -lh
R CMD build AMR R CMD build AMR
R CMD check --no-manual --run-donttest --run-dontrun AMR_*.tar.gz R CMD check --no-manual --run-donttest --run-dontrun AMR_*.tar.gz
shell: bash shell: bash
@ -143,8 +141,6 @@ jobs:
- name: Show unit tests output - name: Show unit tests output
if: always() if: always()
run: | run: |
ls -lh
cd AMR
find . -name 'tinytest.Rout*' -exec cat '{}' \; || true find . -name 'tinytest.Rout*' -exec cat '{}' \; || true
shell: bash shell: bash

View File

@ -33,30 +33,54 @@ name: code-coverage
jobs: jobs:
code-coverage: code-coverage:
runs-on: ubuntu-latest runs-on: macOS-latest
env: env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2 - uses: r-lib/actions/setup-r@v2
with: with:
r-version: release r-version: release
# use RStudio Package Manager to quickly install packages
use-public-rspm: true - uses: r-lib/actions/setup-pandoc@v2
# with:
# pandoc-version: '2.7.3' # The pandoc version to download (if necessary) and use.
- uses: r-lib/actions/setup-r-dependencies@v2 - name: Query dependencies
# this will change once a week, so it will cache dependency updates
run: |
writeLines(paste(format(Sys.Date(), "week %V %Y"), sprintf("R-%i.%i", getRversion()$major, getRversion()$minor)), ".github/week-R-version")
shell: Rscript {0}
- name: Restore cached R packages
# this step will add the step 'Post Restore cached R packages' on a succesful run
uses: actions/cache@v2
with: with:
extra-packages: any::covr path: ${{ env.R_LIBS_USER }}
key: ${{ matrix.config.os }}-${{ hashFiles('.github/week-R-version') }}-v4
- name: Unpack AMR and install R dependencies
run: |
tar -xf data-raw/AMR_latest.tar.gz
Rscript -e "source('data-raw/_install_deps.R')"
shell: bash
- name: Show session info
run: |
options(width = 100)
utils::sessionInfo()
as.data.frame(utils::installed.packages())[, "Version", drop = FALSE]
shell: Rscript {0}
- name: Test coverage - name: Test coverage
env: env:
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
R_RUN_TINYTEST: true R_RUN_TINYTEST: true
run: | run: |
install.packages("covr", repos = "https://cran.rstudio.com/")
library(AMR)
library(tinytest)
x <- covr::codecov(line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/translate.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R")) x <- covr::codecov(line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/translate.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R"))
print(x) print(x)
shell: Rscript {0} shell: Rscript {0}

View File

@ -33,23 +33,34 @@ name: lintr
jobs: jobs:
lintr: lintr:
runs-on: ubuntu-latest runs-on: macOS-latest
env: env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2 - uses: r-lib/actions/setup-r@v2
with:
r-version: release
# use RStudio Package Manager to quickly install packages
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2 - name: Query dependencies
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")
shell: Rscript {0}
- name: Cache R packages
uses: actions/cache@v2
with: with:
extra-packages: any::lintr 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
run: |
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("lintr")
shell: Rscript {0}
- name: Lint - name: Lint
run: lintr::lint_package(linters = lintr::with_defaults(line_length_linter = NULL, trailing_whitespace_linter = NULL, object_name_linter = NULL, cyclocomp_linter = NULL, object_length_linter = lintr::object_length_linter(length = 50L)), exclusions = list("R/aa_helper_pm_functions.R")) run: lintr::lint_package(linters = lintr::with_defaults(line_length_linter = NULL, trailing_whitespace_linter = NULL, object_name_linter = NULL, cyclocomp_linter = NULL, object_length_linter = lintr::object_length_linter(length = 50L)), exclusions = list("R/aa_helper_pm_functions.R"))

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 1.8.1.9040 Version: 1.8.1.9034
Date: 2022-08-28 Date: 2022-08-28
Title: Antimicrobial Resistance Data Analysis Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR) Description: Functions to simplify and standardise antimicrobial resistance (AMR)
@ -42,7 +42,7 @@ Suggests:
rvest, rvest,
tinytest, tinytest,
xml2 xml2
VignetteBuilder: knitr,rmarkdown VignetteBuilder: knitr
URL: https://msberends.github.io/AMR/, https://github.com/msberends/AMR URL: https://msberends.github.io/AMR/, https://github.com/msberends/AMR
BugReports: https://github.com/msberends/AMR/issues BugReports: https://github.com/msberends/AMR/issues
License: GPL-2 | file LICENSE License: GPL-2 | file LICENSE

View File

@ -1,4 +1,4 @@
# AMR 1.8.1.9040 # AMR 1.8.1.9034
### New ### New
* EUCAST 2022 and CLSI 2022 guidelines have been added for `as.rsi()`. EUCAST 2022 is now the new default guideline for all MIC and disks diffusion interpretations. * EUCAST 2022 and CLSI 2022 guidelines have been added for `as.rsi()`. EUCAST 2022 is now the new default guideline for all MIC and disks diffusion interpretations.

View File

@ -651,7 +651,7 @@ dataset_UTF8_to_ASCII <- function(df) {
df[, i] <- col df[, i] <- col
} }
} }
import_fn("as_tibble", "tibble")(df) tibble::as_tibble(df)
} }
# for eucast_rules() and mdro(), creates markdown output with URLs and names # for eucast_rules() and mdro(), creates markdown output with URLs and names

View File

@ -529,7 +529,7 @@ first_isolate <- function(x = NULL,
} }
if (!is.null(col_icu)) { if (!is.null(col_icu)) {
if (icu_exclude == TRUE) { if (icu_exclude == TRUE) {
message_("Excluding ", format(sum(col_icu, na.rm = TRUE), big.mark = ","), " isolates from ICU.", message_("Excluding ", format(sum(!col_icu, na.rm = TRUE), big.mark = ","), " isolates from ICU.",
add_fn = font_black, add_fn = font_black,
as_note = FALSE as_note = FALSE
) )

12
R/mo.R
View File

@ -204,12 +204,12 @@ as.mo <- function(x,
)) ))
} }
reference_df <- repair_reference_df(reference_df)
if (!is.null(reference_df) && if (!is.null(reference_df) &&
check_validity_mo_source(reference_df) && check_validity_mo_source(reference_df) &&
isFALSE(Becker) && isFALSE(Becker) &&
isFALSE(Lancefield) && isFALSE(Lancefield) &&
all(x %in% reference_df[, 1, drop = TRUE], na.rm = TRUE)) { all(x %in% unlist(reference_df), na.rm = TRUE)) {
reference_df <- repair_reference_df(reference_df)
suppressWarnings( suppressWarnings(
y <- data.frame(x = x, stringsAsFactors = FALSE) %pm>% y <- data.frame(x = x, stringsAsFactors = FALSE) %pm>%
pm_left_join(reference_df, by = "x") %pm>% pm_left_join(reference_df, by = "x") %pm>%
@ -221,7 +221,6 @@ as.mo <- function(x,
y <- x y <- x
} else { } else {
# will be checked for mo class in validation and uses exec_as.mo internally if necessary # will be checked for mo class in validation and uses exec_as.mo internally if necessary
y <- mo_validate( y <- mo_validate(
x = x, property = "mo", x = x, property = "mo",
Becker = Becker, Lancefield = Lancefield, Becker = Becker, Lancefield = Lancefield,
@ -421,7 +420,7 @@ exec_as.mo <- function(x,
} }
# all empty # all empty
if (all(identical(trimws(x_input), "") | is.na(x_input) | length(x) == 0, na.rm = TRUE)) { if (all(identical(trimws(x_input), "") | is.na(x_input) | length(x) == 0)) {
if (property == "mo") { if (property == "mo") {
return(set_clean_class(rep(NA_character_, length(x_input)), return(set_clean_class(rep(NA_character_, length(x_input)),
new_class = c("mo", "character") new_class = c("mo", "character")
@ -429,7 +428,7 @@ exec_as.mo <- function(x,
} else { } else {
return(rep(NA_character_, length(x_input))) return(rep(NA_character_, length(x_input)))
} }
} else if (all(x %in% reference_df[, 1, drop = TRUE], na.rm = TRUE)) { } else if (all(x %in% reference_df[, 1, drop = TRUE][[1]])) {
# all in reference df # all in reference df
colnames(reference_df)[1] <- "x" colnames(reference_df)[1] <- "x"
suppressWarnings( suppressWarnings(
@ -2358,9 +2357,6 @@ replace_ignore_pattern <- function(x, ignore_pattern) {
} }
repair_reference_df <- function(reference_df) { repair_reference_df <- function(reference_df) {
if (is.null(reference_df)) {
return(NULL)
}
# has valid own reference_df # has valid own reference_df
reference_df <- reference_df %pm>% reference_df <- reference_df %pm>%
pm_filter(!is.na(mo)) pm_filter(!is.na(mo))

View File

@ -26,6 +26,7 @@
# some old R instances have trouble installing tinytest, so we ship it too # some old R instances have trouble installing tinytest, so we ship it too
install.packages("data-raw/tinytest_1.3.1.tar.gz", dependencies = c("Depends", "Imports", "LinkingTo")) install.packages("data-raw/tinytest_1.3.1.tar.gz", dependencies = c("Depends", "Imports", "LinkingTo"))
install.packages(getwd(), repos = NULL, type = "source") install.packages(getwd(), repos = NULL, type = "source")
# install.packages("data-raw/AMR_latest.tar.gz", dependencies = FALSE)
pkg_suggests <- gsub( pkg_suggests <- gsub(
"[^a-zA-Z0-9]+", "", "[^a-zA-Z0-9]+", "",

View File

@ -475,11 +475,6 @@ rm(current_globalenv)
devtools::load_all(quiet = TRUE) devtools::load_all(quiet = TRUE)
# Update URLs -------------------------------------------------------------
usethis::ui_info("Checking URLs for redirects")
invisible(capture.output(urlchecker::url_update()))
# Document pkg ------------------------------------------------------------ # Document pkg ------------------------------------------------------------
usethis::ui_info("Documenting package") usethis::ui_info("Documenting package")
suppressMessages(devtools::document(quiet = TRUE)) suppressMessages(devtools::document(quiet = TRUE))

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
b57c9cc7380a233a2616a80e8e904a81 19af89838b60bc8549d4474609629e8d

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -47,7 +47,7 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) {
expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE)) expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
} }
# we rely on "grouped_tbl" being a class of grouped tibbles, so run a test that checks for this: # we rely on "grouped_tbl" being a class of grouped tibbles, so implement a test that checks for this:
if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) { if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) {
expect_true(AMR:::is_null_or_grouped_tbl(example_isolates %>% group_by(ward))) expect_true(AMR:::is_null_or_grouped_tbl(example_isolates %>% group_by(ward)))
} }

View File

@ -68,15 +68,15 @@ expect_true(ab_url("AMX") %like% "whocc.no")
expect_warning(ab_url("ASP")) expect_warning(ab_url("ASP"))
expect_identical( expect_identical(
colnames(set_ab_names(example_isolates[, 17:22])), colnames(set_ab_names(example_isolates[, 20:25])),
c("cefoxitin", "cefotaxime", "ceftazidime", "ceftriaxone", "gentamicin", "tobramycin") c("cefoxitin", "cefotaxime", "ceftazidime", "ceftriaxone", "gentamicin", "tobramycin")
) )
expect_identical( expect_identical(
colnames(set_ab_names(example_isolates[, 17:22], language = "nl", snake_case = FALSE)), colnames(set_ab_names(example_isolates[, 20:25], language = "nl", snake_case = FALSE)),
c("Cefoxitine", "Cefotaxim", "Ceftazidim", "Ceftriaxon", "Gentamicine", "Tobramycine") c("Cefoxitine", "Cefotaxim", "Ceftazidim", "Ceftriaxon", "Gentamicine", "Tobramycine")
) )
expect_identical( expect_identical(
colnames(set_ab_names(example_isolates[, 17:22], property = "atc")), colnames(set_ab_names(example_isolates[, 20:25], property = "atc")),
c("J01DC01", "J01DD01", "J01DD02", "J01DD04", "J01GB03", "J01GB01") c("J01DC01", "J01DD01", "J01DD02", "J01DD04", "J01GB03", "J01GB01")
) )

View File

@ -79,7 +79,7 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) {
combination = count_susceptible(CIP, GEN) combination = count_susceptible(CIP, GEN)
) %>% ) %>%
pull(combination), pull(combination),
c(946, 428, 94) c(253, 465, 192, 558)
) )
# count_df # count_df

View File

@ -53,13 +53,12 @@ expect_false(any(is.na(as.disk(rsi_translation[which(rsi_translation$method == "
# antibiotic names must always be coercible to their original AB code # antibiotic names must always be coercible to their original AB code
expect_identical(as.ab(antibiotics$name), antibiotics$ab) expect_identical(as.ab(antibiotics$name), antibiotics$ab)
if (AMR:::pkg_is_available("tibble", also_load = FALSE)) { # there should be no diacritics (i.e. non ASCII) characters in the datasets (CRAN policy)
# there should be no diacritics (i.e. non ASCII) characters in the datasets (CRAN policy) datasets <- data(package = "AMR", envir = asNamespace("AMR"))$results[, "Item", drop = TRUE]
datasets <- data(package = "AMR", envir = asNamespace("AMR"))$results[, "Item", drop = TRUE] for (i in seq_len(length(datasets))) {
for (i in seq_len(length(datasets))) { dataset <- get(datasets[i], envir = asNamespace("AMR"))
dataset <- get(datasets[i], envir = asNamespace("AMR")) expect_identical(class(dataset), "data.frame")
expect_identical(AMR:::dataset_UTF8_to_ASCII(dataset), dataset, info = datasets[i]) expect_identical(AMR:::dataset_UTF8_to_ASCII(dataset), dataset, info = datasets[i])
}
} }
df <- AMR:::MO_lookup df <- AMR:::MO_lookup

View File

@ -75,7 +75,7 @@ expect_equal(
), ),
na.rm = TRUE na.rm = TRUE
), ),
942 941
) )
# set 1500 random observations to be of specimen type 'Urine' # set 1500 random observations to be of specimen type 'Urine'
@ -160,7 +160,7 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) {
# support for WHONET # support for WHONET
expect_message(example_isolates %>% expect_message(example_isolates %>%
select(-patient) %>% select(-patient_id) %>%
mutate( mutate(
`First name` = "test", `First name` = "test",
`Last name` = "test", `Last name` = "test",

View File

@ -84,7 +84,7 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) {
combination_n = n_rsi(CIP, GEN) combination_n = n_rsi(CIP, GEN)
) %>% ) %>%
pull(combination_n), pull(combination_n),
c(1181, 577, 116) c(305, 617, 241, 711)
) )
# proportion_df # proportion_df

View File

@ -27,9 +27,8 @@
if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) { if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) {
# env var 'R_LIBS_USER' got overwritten during 'R CMD check' in GitHub Actions, so: # env var 'R_LIBS_USER' got overwritten during 'R CMD check' in GitHub Actions, so:
.libPaths(c(Sys.getenv("R_LIBS_USER_GH_ACTIONS"), .libPaths())) .libPaths(c(Sys.getenv("R_LIBS_USER_GH_ACTIONS"), .libPaths()))
if (AMR:::pkg_is_available("tinytest", also_load = TRUE)) { if (AMR:::pkg_is_available("tinytest")) {
library(AMR) library(AMR)
set_AMR_locale("English")
out <- test_package("AMR", out <- test_package("AMR",
testdir = ifelse(AMR:::dir.exists("inst/tinytest"), testdir = ifelse(AMR:::dir.exists("inst/tinytest"),
"inst/tinytest", "inst/tinytest",
@ -38,7 +37,7 @@ if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) {
verbose = 99, verbose = 99,
color = FALSE color = FALSE
) )
cat("\n\nSUMMARY:\n") cat("SUMMARY:\n")
print(summary(out)) print(summary(out))
} }
} }