(v2.1.1.9273) fix as.ab() / as.av()

This commit is contained in:
dr. M.S. (Matthijs) Berends committed 2025-05-05 11:45:33 +02:00
1 parent fcd8b95e51
commit 3f9012dc47
4 files changed
+9 -9

No files matched your search

+2 -2
View File
@@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 2.1.1.9272 Version: 2.1.1.9273
Date: 2025-05-04 Date: 2025-05-05
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)
data analysis and to work with microbial and antimicrobial properties by data analysis and to work with microbial and antimicrobial properties by
+1 -1
View File
@@ -1,4 +1,4 @@
# AMR 2.1.1.9272 # AMR 2.1.1.9273
*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://amr-for-r.org/#get-this-package).)* *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://amr-for-r.org/#get-this-package).)*
+6 -6
View File
@@ -282,7 +282,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, language = get_AMR_locale(),
levenshtein <- as.double(utils::adist(x[i], AMR_env$AB_lookup$generalised_name, levenshtein <- as.double(utils::adist(x[i], AMR_env$AB_lookup$generalised_name,
ignore.case = FALSE, ignore.case = FALSE,
fixed = TRUE, fixed = TRUE,
costs = c(insertions = 1, deletions = 1, substitutions = 3), costs = c(insertions = 1, deletions = 1, substitutions = 2),
counts = FALSE counts = FALSE
)) ))
if (any(levenshtein <= 2)) { if (any(levenshtein <= 2)) {
@@ -355,7 +355,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, language = get_AMR_locale(),
ab_df$lev_name <- as.double(utils::adist(x[i], ab_df$generalised_name, ab_df$lev_name <- as.double(utils::adist(x[i], ab_df$generalised_name,
ignore.case = FALSE, ignore.case = FALSE,
fixed = TRUE, fixed = TRUE,
costs = c(insertions = 1, deletions = 1, substitutions = 3), costs = c(insertions = 1, deletions = 1, substitutions = 2),
counts = FALSE counts = FALSE
)) ))
ab_df$lev_syn <- vapply( ab_df$lev_syn <- vapply(
@@ -367,7 +367,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, language = get_AMR_locale(),
min(as.double(utils::adist(x[i], y[nchar(y) >= 5], min(as.double(utils::adist(x[i], y[nchar(y) >= 5],
ignore.case = FALSE, ignore.case = FALSE,
fixed = TRUE, fixed = TRUE,
costs = c(insertions = 1, deletions = 1, substitutions = 3), costs = c(insertions = 1, deletions = 1, substitutions = 2),
counts = FALSE counts = FALSE
)), na.rm = TRUE) )), na.rm = TRUE)
) )
@@ -379,7 +379,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, language = get_AMR_locale(),
ab_df$lev_trans <- as.double(utils::adist(x[i], ab_df$trans, ab_df$lev_trans <- as.double(utils::adist(x[i], ab_df$trans,
ignore.case = FALSE, ignore.case = FALSE,
fixed = TRUE, fixed = TRUE,
costs = c(insertions = 1, deletions = 1, substitutions = 3), costs = c(insertions = 1, deletions = 1, substitutions = 2),
counts = FALSE counts = FALSE
)) ))
} else { } else {
@@ -651,8 +651,8 @@ generalise_antibiotic_name <- function(x) {
x <- gsub("(/| AND | WITH | W/|[+]|[-])+", " ", x, perl = TRUE) x <- gsub("(/| AND | WITH | W/|[+]|[-])+", " ", x, perl = TRUE)
# replace more than 1 space # replace more than 1 space
x <- trimws(gsub(" +", " ", x, perl = TRUE)) x <- trimws(gsub(" +", " ", x, perl = TRUE))
# remove last couple of words if they are 1-3 characters # remove last couple of words if they numbers or units
x <- gsub("( .{1,3})+$", "", x) x <- gsub(" ([0-9]{3,99}|U?M?C?G)+$", "", x)
# move HIGH to end # move HIGH to end
x <- trimws(gsub("(.*) HIGH(.*)", "\\1\\2 HIGH", x, perl = TRUE)) x <- trimws(gsub("(.*) HIGH(.*)", "\\1\\2 HIGH", x, perl = TRUE))
x x
BIN
View File
Binary file not shown.