1
0
mirror of https://github.com/msberends/AMR.git synced 2025-06-07 19:14:01 +02:00

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

This commit is contained in:
dr. M.S. (Matthijs) Berends 2025-05-05 11:45:33 +02:00
parent fcd8b95e51
commit 3f9012dc47
No known key found for this signature in database
4 changed files with 9 additions and 9 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 2.1.1.9272
Date: 2025-05-04
Version: 2.1.1.9273
Date: 2025-05-05
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
data analysis and to work with microbial and antimicrobial properties by

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).)*

12
R/ab.R
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,
ignore.case = FALSE,
fixed = TRUE,
costs = c(insertions = 1, deletions = 1, substitutions = 3),
costs = c(insertions = 1, deletions = 1, substitutions = 2),
counts = FALSE
))
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,
ignore.case = FALSE,
fixed = TRUE,
costs = c(insertions = 1, deletions = 1, substitutions = 3),
costs = c(insertions = 1, deletions = 1, substitutions = 2),
counts = FALSE
))
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],
ignore.case = FALSE,
fixed = TRUE,
costs = c(insertions = 1, deletions = 1, substitutions = 3),
costs = c(insertions = 1, deletions = 1, substitutions = 2),
counts = FALSE
)), 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,
ignore.case = FALSE,
fixed = TRUE,
costs = c(insertions = 1, deletions = 1, substitutions = 3),
costs = c(insertions = 1, deletions = 1, substitutions = 2),
counts = FALSE
))
} else {
@ -651,8 +651,8 @@ generalise_antibiotic_name <- function(x) {
x <- gsub("(/| AND | WITH | W/|[+]|[-])+", " ", x, perl = TRUE)
# replace more than 1 space
x <- trimws(gsub(" +", " ", x, perl = TRUE))
# remove last couple of words if they are 1-3 characters
x <- gsub("( .{1,3})+$", "", x)
# remove last couple of words if they numbers or units
x <- gsub(" ([0-9]{3,99}|U?M?C?G)+$", "", x)
# move HIGH to end
x <- trimws(gsub("(.*) HIGH(.*)", "\\1\\2 HIGH", x, perl = TRUE))
x

Binary file not shown.