mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 07:26:12 +01:00
complexes
This commit is contained in:
parent
f6862a139d
commit
05d536ebb7
@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.8.2.9051
|
Version: 1.8.2.9052
|
||||||
Date: 2022-11-14
|
Date: 2022-11-17
|
||||||
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
|
||||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
|||||||
# AMR 1.8.2.9051
|
# AMR 1.8.2.9052
|
||||||
|
|
||||||
This version will eventually become v2.0! We're happy to reach a new major milestone soon!
|
This version will eventually become v2.0! We're happy to reach a new major milestone soon!
|
||||||
|
|
||||||
|
6
R/mo.R
6
R/mo.R
@ -180,6 +180,10 @@ as.mo <- function(x,
|
|||||||
x <- replace_ignore_pattern(x, ignore_pattern)
|
x <- replace_ignore_pattern(x, ignore_pattern)
|
||||||
|
|
||||||
x_lower <- tolower(x)
|
x_lower <- tolower(x)
|
||||||
|
|
||||||
|
if (any(trimws2(x_lower) %like_case% "complex$", na.rm = TRUE)) {
|
||||||
|
warning_("in `as.mo()`: translation of complexes is not supported at the moment - the input text 'complex' was ignored.", call = FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
# WHONET: xxx = no growth
|
# WHONET: xxx = no growth
|
||||||
x[x_lower %in% c("", "xxx", "na", "nan")] <- NA_character_
|
x[x_lower %in% c("", "xxx", "na", "nan")] <- NA_character_
|
||||||
@ -521,7 +525,7 @@ mo_cleaning_regex <- function() {
|
|||||||
"|",
|
"|",
|
||||||
"([({]|\\[).+([})]|\\])",
|
"([({]|\\[).+([})]|\\])",
|
||||||
"|",
|
"|",
|
||||||
"(^| )(e?spp|e?ssp|e?ss|e?sp|e?subsp|sube?species|biovar|biotype|serovar|e?species)[.]*( |$))"
|
"(^| )(e?spp|e?ssp|e?ss|e?sp|e?subsp|sube?species|biovar|biotype|serovar|serogr.?up|e?species|complex)[.]*( |$))"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
R/rsi.R
7
R/rsi.R
@ -285,7 +285,7 @@ as.rsi.default <- function(x, ...) {
|
|||||||
|
|
||||||
x.bak <- x
|
x.bak <- x
|
||||||
x <- as.character(x) # this is needed to prevent the vctrs pkg from throwing an error
|
x <- as.character(x) # this is needed to prevent the vctrs pkg from throwing an error
|
||||||
|
|
||||||
if (inherits(x.bak, c("integer", "numeric", "double")) && all(x %in% c(1:3, NA))) {
|
if (inherits(x.bak, c("integer", "numeric", "double")) && all(x %in% c(1:3, NA))) {
|
||||||
# support haven package for importing e.g., from SPSS - it adds the 'labels' attribute
|
# support haven package for importing e.g., from SPSS - it adds the 'labels' attribute
|
||||||
lbls <- attributes(x.bak)$labels
|
lbls <- attributes(x.bak)$labels
|
||||||
@ -298,6 +298,10 @@ as.rsi.default <- function(x, ...) {
|
|||||||
x[x.bak == 2] <- "I"
|
x[x.bak == 2] <- "I"
|
||||||
x[x.bak == 3] <- "R"
|
x[x.bak == 3] <- "R"
|
||||||
}
|
}
|
||||||
|
} else if (inherits(x.bak, "character") && all(x %in% c("1", "2", "3", "S", "I", "R", NA_character_))) {
|
||||||
|
x[x.bak == "1"] <- "S"
|
||||||
|
x[x.bak == "2"] <- "I"
|
||||||
|
x[x.bak == "3"] <- "R"
|
||||||
} else if (!all(is.na(x)) && !identical(levels(x), c("R", "S", "I")) && !all(x %in% c("R", "S", "I", NA))) {
|
} else if (!all(is.na(x)) && !identical(levels(x), c("R", "S", "I")) && !all(x %in% c("R", "S", "I", NA))) {
|
||||||
if (all(x %unlike% "(R|S|I)", na.rm = TRUE)) {
|
if (all(x %unlike% "(R|S|I)", na.rm = TRUE)) {
|
||||||
# check if they are actually MICs or disks
|
# check if they are actually MICs or disks
|
||||||
@ -312,6 +316,7 @@ as.rsi.default <- function(x, ...) {
|
|||||||
x <- trimws2(as.character(unlist(x)))
|
x <- trimws2(as.character(unlist(x)))
|
||||||
x[x %in% c(NA, "", "-", "NULL")] <- NA_character_
|
x[x %in% c(NA, "", "-", "NULL")] <- NA_character_
|
||||||
x.bak <- x
|
x.bak <- x
|
||||||
|
|
||||||
na_before <- length(x[is.na(x)])
|
na_before <- length(x[is.na(x)])
|
||||||
|
|
||||||
# correct for translations
|
# correct for translations
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# `AMR` (for R)
|
# `AMR` (for R)
|
||||||
|
|
||||||
<a href="https://msberends.github.io/AMR/"><img src="https://msberends.github.io/AMR/AMR_intro.svg" align="center"></a>
|
<a href="https://msberends.github.io/AMR/"><img src="https://msberends.github.io/AMR/AMR_intro.png" align="center"></a>
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -80,6 +80,8 @@ expect_equal(as.character(as.mo("streptococcus milleri")), "B_STRPT_MILL")
|
|||||||
|
|
||||||
expect_equal(as.character(as.mo(c("Gram negative", "Gram positive"))), c("B_GRAMN", "B_GRAMP"))
|
expect_equal(as.character(as.mo(c("Gram negative", "Gram positive"))), c("B_GRAMN", "B_GRAMP"))
|
||||||
|
|
||||||
|
expect_warning(as.mo("Acinetobacter calcoaceticus/baumannii complex"))
|
||||||
|
|
||||||
# prevalent MO
|
# prevalent MO
|
||||||
expect_identical(
|
expect_identical(
|
||||||
suppressWarnings(as.character(
|
suppressWarnings(as.character(
|
||||||
|
@ -81,6 +81,12 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) {
|
|||||||
expect_equal(sum(is.rsi(example_isolates)), 40)
|
expect_equal(sum(is.rsi(example_isolates)), 40)
|
||||||
|
|
||||||
expect_stdout(print(tibble(ab = as.rsi("S"))))
|
expect_stdout(print(tibble(ab = as.rsi("S"))))
|
||||||
|
|
||||||
|
expect_true(example_isolates %>%
|
||||||
|
select(AMC, MEM) %>%
|
||||||
|
mutate(MEM = as.rsi(ifelse(AMC == "S", "S", MEM))) %>%
|
||||||
|
pull(MEM) %>%
|
||||||
|
is.rsi())
|
||||||
}
|
}
|
||||||
if (AMR:::pkg_is_available("skimr", min_version = "2.0.0")) {
|
if (AMR:::pkg_is_available("skimr", min_version = "2.0.0")) {
|
||||||
expect_inherits(
|
expect_inherits(
|
||||||
|
Loading…
Reference in New Issue
Block a user