1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 18:06:12 +01:00

coercion fixes

This commit is contained in:
dr. M.S. (Matthijs) Berends 2022-10-19 06:59:36 +02:00
parent 3fc39198d0
commit f203928f7e
5 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 1.8.2.9020
Date: 2022-10-18
Version: 1.8.2.9021
Date: 2022-10-19
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 1.8.2.9020
# AMR 1.8.2.9021
This version will eventually become v2.0! We're happy to reach a new major milestone soon!

2
R/mo.R
View File

@ -440,7 +440,7 @@ as.mo <- function(x,
# All unknowns ----
out[is.na(out) & !is.na(x)] <- "UNKNOWN"
AMR_env$mo_failures <- unique(x[out == "UNKNOWN" & x != "UNKNOWN" & !is.na(x)])
AMR_env$mo_failures <- unique(x[out == "UNKNOWN" & !x %in% c("UNKNOWN", "con") & !x %like_case% "^[(]unknown [a-z]+[)]$" & !is.na(x)])
if (length(AMR_env$mo_failures) > 0) {
warning_("The following input could not be coerced and was returned as \"UNKNOWN\": ", vector_and(AMR_env$mo_failures, quotes = TRUE), ".\nYou can retrieve this list with `mo_failures()`.")
}

View File

@ -51,7 +51,6 @@ expect_stdout(print(data.frame(a = as.ab("amox"))))
expect_warning(as.ab("J00AA00")) # ATC not yet available in data set
expect_warning(as.ab("UNKNOWN"))
expect_warning(as.ab(""))
expect_stdout(print(as.ab("amox")))
@ -75,7 +74,7 @@ expect_equal(
c("MEM", "AMC")
)
expect_message(as.ab("cipro mero"))
expect_warning(as.ab("cipro mero"))
# based on Levenshtein distance
expect_identical(ab_name("ceftazidim/avibactam", language = NULL), "Ceftazidime/avibactam")
@ -86,6 +85,7 @@ expect_inherits(x[1], "ab")
expect_inherits(x[[1]], "ab")
expect_inherits(c(x[1], x[9]), "ab")
expect_inherits(unique(x[1], x[9]), "ab")
expect_inherits(rep(x[1], x[9]), "ab")
expect_warning(x[1] <- "invalid code")
expect_warning(x[[1]] <- "invalid code")
expect_warning(c(x[1], "test"))

View File

@ -283,7 +283,7 @@ expect_equal(
)
# no viruses
expect_equal(as.mo("Virus"), as.mo("UNKNOWN"))
expect_equal(suppressWarnings(as.mo("Virus")), as.mo("UNKNOWN"))
# summary
expect_equal(length(summary(example_isolates$mo)), 6)