mirror of
https://github.com/msberends/AMR.git
synced 2026-03-30 11:35:54 +02:00
fixes
This commit is contained in:
@@ -1061,7 +1061,7 @@ get_current_data <- function(arg_name, call) {
|
|||||||
} else {
|
} else {
|
||||||
examples <- ""
|
examples <- ""
|
||||||
}
|
}
|
||||||
stop_("this function must be used inside a {.pkg dplyr} verb or {.code data.frame} call",
|
stop_("this function must be used inside a {.pkg dplyr} verb or {.cls data.frame} call",
|
||||||
examples,
|
examples,
|
||||||
call = call
|
call = call
|
||||||
)
|
)
|
||||||
|
|||||||
24
R/ab.R
24
R/ab.R
@@ -484,7 +484,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, language = get_AMR_locale(),
|
|||||||
}
|
}
|
||||||
message_(
|
message_(
|
||||||
"Antimicrobial translation was uncertain for ", examples,
|
"Antimicrobial translation was uncertain for ", examples,
|
||||||
". If required, use `add_custom_antimicrobials()` to add custom entries."
|
". If required, use {.help [{.fun add_custom_antimicrobials}](AMR::add_custom_antimicrobials)} to add custom entries."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -556,21 +556,21 @@ print.ab <- function(x, ...) {
|
|||||||
function_name <- attributes(x)$amr_selector
|
function_name <- attributes(x)$amr_selector
|
||||||
if (pkg_is_available("cli", min_version = "3.0.0")) {
|
if (pkg_is_available("cli", min_version = "3.0.0")) {
|
||||||
cli::cli_inform(c(
|
cli::cli_inform(c(
|
||||||
"i" = paste0("This {.cls ab} vector was retrieved using {.fun ", function_name, "}, which should normally be used inside a {.pkg dplyr} verb or {.code data.frame} call, e.g.:"),
|
"i" = paste0("This {.cls ab} vector was retrieved using {.fun ", function_name, "}, which should normally be used inside a {.pkg dplyr} verb or {.cls data.frame} call, e.g.:"),
|
||||||
"*" = highlight_code(paste0("your_data %>% select(", function_name, "()")),
|
paste0("\u00a0\u00a0", AMR_env$bullet_icon, " ", highlight_code(paste0("your_data %>% select(", function_name, "())"))),
|
||||||
"*" = highlight_code(paste0("your_data %>% select(column_a, column_b, ", function_name, "()")),
|
paste0("\u00a0\u00a0", AMR_env$bullet_icon, " ", highlight_code(paste0("your_data %>% select(column_a, column_b, ", function_name, "())"))),
|
||||||
"*" = highlight_code(paste0("your_data %>% filter(any(", function_name, "() == \"R\"))")),
|
paste0("\u00a0\u00a0", AMR_env$bullet_icon, " ", highlight_code(paste0("your_data %>% filter(any(", function_name, "() == \"R\"))"))),
|
||||||
"*" = highlight_code(paste0("your_data[, ", function_name, "()]")),
|
paste0("\u00a0\u00a0", AMR_env$bullet_icon, " ", highlight_code(paste0("your_data[, ", function_name, "()]"))),
|
||||||
"*" = highlight_code(paste0("your_data[, c(\"column_a\", \"column_b\", ", function_name, "())]"))
|
paste0("\u00a0\u00a0", AMR_env$bullet_icon, " ", highlight_code(paste0("your_data[, c(\"column_a\", \"column_b\", ", function_name, "())]")))
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
message(word_wrap(paste0(
|
message(word_wrap(paste0(
|
||||||
"This 'ab' vector was retrieved using `", function_name, "()`, which should normally be used inside a dplyr verb or data.frame call, e.g.:\n",
|
"This 'ab' vector was retrieved using `", function_name, "()`, which should normally be used inside a dplyr verb or data.frame call, e.g.:\n",
|
||||||
" ", AMR_env$bullet_icon, " your_data %>% select(", function_name, "())\n",
|
"\u00a0\u00a0", AMR_env$bullet_icon, " your_data %>% select(", function_name, "())\n",
|
||||||
" ", AMR_env$bullet_icon, " your_data %>% select(column_a, column_b, ", function_name, "())\n",
|
"\u00a0\u00a0", AMR_env$bullet_icon, " your_data %>% select(column_a, column_b, ", function_name, "())\n",
|
||||||
" ", AMR_env$bullet_icon, " your_data %>% filter(any(", function_name, "() == \"R\"))\n",
|
"\u00a0\u00a0", AMR_env$bullet_icon, " your_data %>% filter(any(", function_name, "() == \"R\"))\n",
|
||||||
" ", AMR_env$bullet_icon, " your_data[, ", function_name, "()]\n",
|
"\u00a0\u00a0", AMR_env$bullet_icon, " your_data[, ", function_name, "()]\n",
|
||||||
" ", AMR_env$bullet_icon, " your_data[, c(\"column_a\", \"column_b\", ", function_name, "())]"
|
"\u00a0\u00a0", AMR_env$bullet_icon, " your_data[, c(\"column_a\", \"column_b\", ", function_name, "())]"
|
||||||
), as_note = TRUE))
|
), as_note = TRUE))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -722,7 +722,7 @@ amr_select_exec <- function(function_name,
|
|||||||
if (any(untreatable %in% names(ab_in_data))) {
|
if (any(untreatable %in% names(ab_in_data))) {
|
||||||
if (message_not_thrown_before(function_name, "amr_class", "untreatable")) {
|
if (message_not_thrown_before(function_name, "amr_class", "untreatable")) {
|
||||||
warning_(
|
warning_(
|
||||||
"in `", function_name, "()`: some drugs were ignored since they cannot be used for treatment: ",
|
"in {.help [{.fun ", function_name, "}](AMR::", function_name, ")}: some drugs were ignored since they cannot be used for treatment: ",
|
||||||
vector_and(
|
vector_and(
|
||||||
ab_name(names(ab_in_data)[names(ab_in_data) %in% untreatable],
|
ab_name(names(ab_in_data)[names(ab_in_data) %in% untreatable],
|
||||||
language = NULL,
|
language = NULL,
|
||||||
@@ -797,7 +797,7 @@ amr_select_exec <- function(function_name,
|
|||||||
if (only_treatable == TRUE) {
|
if (only_treatable == TRUE) {
|
||||||
if (message_not_thrown_before(function_name, "amr_class", "untreatable")) {
|
if (message_not_thrown_before(function_name, "amr_class", "untreatable")) {
|
||||||
message_(
|
message_(
|
||||||
"in `", function_name, "()`: ",
|
"in {.help [{.fun ", function_name, "}](AMR::", function_name, ")}: ",
|
||||||
vector_and(
|
vector_and(
|
||||||
paste0(
|
paste0(
|
||||||
ab_name(abx[abx %in% untreatable],
|
ab_name(abx[abx %in% untreatable],
|
||||||
|
|||||||
@@ -235,9 +235,9 @@ print.custom_mdro_guideline <- function(x, ...) {
|
|||||||
for (i in seq_len(length(x))) {
|
for (i in seq_len(length(x))) {
|
||||||
rule <- x[[i]]
|
rule <- x[[i]]
|
||||||
rule$query <- format_custom_query_rule(rule$query)
|
rule$query <- format_custom_query_rule(rule$query)
|
||||||
cat(" ", i, ". ", font_bold("If "), font_blue(rule$query), font_bold(" then: "), font_red(rule$value), "\n", sep = "")
|
cat("\u00a0\u00a0", i, ". ", font_bold("If "), font_blue(rule$query), font_bold(" then: "), font_red(rule$value), "\n", sep = "")
|
||||||
}
|
}
|
||||||
cat(" ", i + 1, ". ", font_bold("Otherwise: "), font_red(paste0("Negative")), "\n", sep = "")
|
cat("\u00a0\u00a0", i + 1, ". ", font_bold("Otherwise: "), font_red(paste0("Negative")), "\n", sep = "")
|
||||||
cat("\nUnmatched rows will return ", font_red("NA"), ".\n", sep = "")
|
cat("\nUnmatched rows will return ", font_red("NA"), ".\n", sep = "")
|
||||||
if (isTRUE(attributes(x)$as_factor)) {
|
if (isTRUE(attributes(x)$as_factor)) {
|
||||||
cat("Results will be of class 'factor', with ordered levels: ", paste0(attributes(x)$values, collapse = " < "), "\n", sep = "")
|
cat("Results will be of class 'factor', with ordered levels: ", paste0(attributes(x)$values, collapse = " < "), "\n", sep = "")
|
||||||
|
|||||||
4
R/mo.R
4
R/mo.R
@@ -977,8 +977,8 @@ print.mo_uncertainties <- function(x, n = 10, ...) {
|
|||||||
|
|
||||||
out <- paste0(
|
out <- paste0(
|
||||||
paste0(
|
paste0(
|
||||||
"", strrep(font_grey("-"), times = getOption("width", 100)), "\n",
|
"", strrep(font_grey("-"), times = getOption("width", 100) - 1), "\n",
|
||||||
'"', x[i, ]$original_input, '"',
|
"{.val ", x[i, ]$original_input, "}",
|
||||||
" -> ",
|
" -> ",
|
||||||
paste0(
|
paste0(
|
||||||
font_bold(italicise(x[i, ]$fullname)),
|
font_bold(italicise(x[i, ]$fullname)),
|
||||||
|
|||||||
2
R/sir.R
2
R/sir.R
@@ -1946,7 +1946,7 @@ as_sir_method <- function(method_short,
|
|||||||
message_(notes[i], as_note = FALSE)
|
message_(notes[i], as_note = FALSE)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
# message(word_wrap(" ", AMR_env$bullet_icon, " There were multiple notes. Print or View `sir_interpretation_history()` to examine them, or use `as.sir(..., verbose = TRUE)` next time to directly print them here.", add_fn = font_black))
|
# message(word_wrap("\u00a0\u00a0", AMR_env$bullet_icon, " There were multiple notes. Print or View `sir_interpretation_history()` to examine them, or use `as.sir(..., verbose = TRUE)` next time to directly print them here.", add_fn = font_black))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message(font_green_bg(" OK "))
|
message(font_green_bg(" OK "))
|
||||||
|
|||||||
@@ -272,8 +272,6 @@ test_that("test-mo.R", {
|
|||||||
)
|
)
|
||||||
|
|
||||||
x <- as.mo("Sta. aur")
|
x <- as.mo("Sta. aur")
|
||||||
# many hits
|
|
||||||
expect_output(print(mo_uncertainties()))
|
|
||||||
|
|
||||||
# no viruses
|
# no viruses
|
||||||
expect_equal(suppressWarnings(as.mo("Virus")), as.mo("UNKNOWN"))
|
expect_equal(suppressWarnings(as.mo("Virus")), as.mo("UNKNOWN"))
|
||||||
|
|||||||
Reference in New Issue
Block a user