mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 19:26:13 +01:00
Fixes #57
This commit is contained in:
parent
1e4eaf23f2
commit
2ed5f13880
9
.github/prehooks/pre-commit
vendored
9
.github/prehooks/pre-commit
vendored
@ -3,25 +3,24 @@
|
|||||||
echo "Running pre-commit hook..."
|
echo "Running pre-commit hook..."
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
echo ">> Updating R documentation..."
|
|
||||||
if command -v Rscript > /dev/null; then
|
if command -v Rscript > /dev/null; then
|
||||||
if [ "$(Rscript -e 'cat(all(c('"'pkgload'"', '"'devtools'"', '"'dplyr'"', '"'styler'"') %in% rownames(installed.packages())))')" = "TRUE" ]; then
|
if [ "$(Rscript -e 'cat(all(c('"'pkgload'"', '"'devtools'"', '"'dplyr'"', '"'styler'"') %in% rownames(installed.packages())))')" = "TRUE" ]; then
|
||||||
Rscript -e "source('data-raw/_pre_commit_hook.R')"
|
Rscript -e "source('data-raw/_pre_commit_hook.R')"
|
||||||
currentpkg=`Rscript -e "cat(pkgload::pkg_name())"`
|
currentpkg=`Rscript -e "cat(pkgload::pkg_name())"`
|
||||||
echo ">> Adding all files in folders 'data-raw', 'inst', 'man', and 'R' to this git commit"
|
echo "-> Adding all files in folders 'data-raw', 'inst', 'man', and 'R' to this git commit"
|
||||||
git add data-raw/*
|
git add data-raw/*
|
||||||
git add inst/*
|
git add inst/*
|
||||||
git add man/*
|
git add man/*
|
||||||
git add R/*
|
git add R/*
|
||||||
else
|
else
|
||||||
echo ">> R package 'pkgload', 'devtools', 'dplyr', or 'styler' not installed!"
|
echo "- R package 'pkgload', 'devtools', 'dplyr', or 'styler' not installed!"
|
||||||
currentpkg="your"
|
currentpkg="your"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo ">> R is not available on your system!"
|
echo "- R is not available on your system!"
|
||||||
currentpkg="your"
|
currentpkg="your"
|
||||||
fi
|
fi
|
||||||
echo ">> "
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
2
.github/workflows/check.yaml
vendored
2
.github/workflows/check.yaml
vendored
@ -130,7 +130,7 @@ jobs:
|
|||||||
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
_R_CHECK_LENGTH_1_CONDITION_: verbose
|
||||||
_R_CHECK_LENGTH_1_LOGIC2_: verbose
|
_R_CHECK_LENGTH_1_LOGIC2_: verbose
|
||||||
# no check for old R versions - these packages require higher R versions
|
# no check for old R versions - these packages require higher R versions
|
||||||
_R_CHECK_RD_XREFS_: {{ matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2' && matrix.config.r != '3.3' && matrix.config.r != '3.4' }}
|
_R_CHECK_RD_XREFS_: ${{ matrix.config.r != '3.0' && matrix.config.r != '3.1' && matrix.config.r != '3.2' && matrix.config.r != '3.3' && matrix.config.r != '3.4' }}
|
||||||
_R_CHECK_FORCE_SUGGESTS_: false
|
_R_CHECK_FORCE_SUGGESTS_: false
|
||||||
R_CHECK_CONSTANTS: 5
|
R_CHECK_CONSTANTS: 5
|
||||||
R_JIT_STRATEGY: 3
|
R_JIT_STRATEGY: 3
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.8.1.9042
|
Version: 1.8.1.9043
|
||||||
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)
|
||||||
|
3
NEWS.md
3
NEWS.md
@ -1,4 +1,4 @@
|
|||||||
# AMR 1.8.1.9042
|
# AMR 1.8.1.9043
|
||||||
|
|
||||||
### 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.
|
||||||
@ -21,6 +21,7 @@
|
|||||||
* All data sets in this package are now exported as `tibble`, instead of base R `data.frame`s. Older R versions are still supported.
|
* All data sets in this package are now exported as `tibble`, instead of base R `data.frame`s. Older R versions are still supported.
|
||||||
* Automatic language determination will give a note once a session
|
* Automatic language determination will give a note once a session
|
||||||
* For all interpretation guidelines using `as.rsi()` on amoxicillin, the rules for ampicillin will be used if amoxicillin rules are not available
|
* For all interpretation guidelines using `as.rsi()` on amoxicillin, the rules for ampicillin will be used if amoxicillin rules are not available
|
||||||
|
* Fix for using `ab_atc()` on non-existing ATC codes
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
* New website to make use of the new Bootstrap 5 and pkgdown v2.0. The website now contains results for all examples and will be automatically regenerated with every change to our repository, using GitHub Actions
|
* New website to make use of the new Bootstrap 5 and pkgdown v2.0. The website now contains results for all examples and will be automatically regenerated with every change to our repository, using GitHub Actions
|
||||||
|
15
R/ab.R
15
R/ab.R
@ -125,6 +125,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
|||||||
x <- unique(x_bak_clean) # this means that every x is in fact generalise_antibiotic_name(x)
|
x <- unique(x_bak_clean) # this means that every x is in fact generalise_antibiotic_name(x)
|
||||||
x_new <- rep(NA_character_, length(x))
|
x_new <- rep(NA_character_, length(x))
|
||||||
x_unknown <- character(0)
|
x_unknown <- character(0)
|
||||||
|
x_unknown_ATCs <- character(0)
|
||||||
|
|
||||||
note_if_more_than_one_found <- function(found, index, from_text) {
|
note_if_more_than_one_found <- function(found, index, from_text) {
|
||||||
if (initial_search == TRUE & isTRUE(length(from_text) > 1)) {
|
if (initial_search == TRUE & isTRUE(length(from_text) > 1)) {
|
||||||
@ -183,6 +184,13 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
|||||||
x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1])
|
x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1])
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
if (x[i] %like_case% "[A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9]") {
|
||||||
|
# seems an ATC code, but the available ones are in `already_known`, so:
|
||||||
|
x_unknown <- c(x_unknown, x[i])
|
||||||
|
x_unknown_ATCs <- c(x_unknown_ATCs, x[i])
|
||||||
|
x_new[i] <- NA_character_
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
if (fast_mode == FALSE && flag_multiple_results == TRUE && x[i] %like% "[ ]") {
|
if (fast_mode == FALSE && flag_multiple_results == TRUE && x[i] %like% "[ ]") {
|
||||||
from_text <- tryCatch(suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]]),
|
from_text <- tryCatch(suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]]),
|
||||||
@ -474,16 +482,15 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# take failed ATC codes apart from rest
|
# take failed ATC codes apart from rest
|
||||||
x_unknown_ATCs <- x_unknown[x_unknown %like% "[A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9]"]
|
if (length(x_unknown_ATCs) > 0 && fast_mode == FALSE) {
|
||||||
x_unknown <- x_unknown[!x_unknown %in% x_unknown_ATCs]
|
|
||||||
if (length(x_unknown_ATCs) > 0 & fast_mode == FALSE) {
|
|
||||||
warning_(
|
warning_(
|
||||||
"in `as.ab()`: these ATC codes are not (yet) in the antibiotics data set: ",
|
"in `as.ab()`: these ATC codes are not (yet) in the antibiotics data set: ",
|
||||||
vector_and(x_unknown_ATCs), "."
|
vector_and(x_unknown_ATCs), "."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
x_unknown <- x_unknown[!x_unknown %in% x_unknown_ATCs]
|
||||||
|
|
||||||
if (length(x_unknown) > 0 & fast_mode == FALSE) {
|
if (length(x_unknown) > 0 && fast_mode == FALSE) {
|
||||||
warning_(
|
warning_(
|
||||||
"in `as.ab()`: these values could not be coerced to a valid antimicrobial ID: ",
|
"in `as.ab()`: these values could not be coerced to a valid antimicrobial ID: ",
|
||||||
vector_and(x_unknown), "."
|
vector_and(x_unknown), "."
|
||||||
|
@ -457,9 +457,13 @@ ab_validate <- function(x, property, ...) {
|
|||||||
|
|
||||||
if (!all(x %in% AB_lookup[, property, drop = TRUE])) {
|
if (!all(x %in% AB_lookup[, property, drop = TRUE])) {
|
||||||
x <- as.ab(x, ...)
|
x <- as.ab(x, ...)
|
||||||
|
if (all(is.na(x)) && is.list(AB_lookup[, property, drop = TRUE])) {
|
||||||
|
x <- rep(NA_character_, length(x))
|
||||||
|
} else {
|
||||||
x <- AB_lookup[match(x, AB_lookup$ab), property, drop = TRUE]
|
x <- AB_lookup[match(x, AB_lookup$ab), property, drop = TRUE]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (property == "ab") {
|
if (property == "ab") {
|
||||||
return(set_clean_class(x, new_class = c("ab", "character")))
|
return(set_clean_class(x, new_class = c("ab", "character")))
|
||||||
|
Loading…
Reference in New Issue
Block a user