1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-12 15:02:00 +02:00

fix sorting of MICs, MIC autoplot titles

This commit is contained in:
2024-05-30 15:50:17 +02:00
parent c3ce1b551d
commit d4490c7f25
7 changed files with 18 additions and 8 deletions

View File

@ -889,6 +889,7 @@ eucast_rules <- function(x,
),
type = "ansi"
))
cat("\n")
warned <- FALSE
}
run_changes <- edit_sir(

11
R/mic.R
View File

@ -495,12 +495,17 @@ rep.mic <- function(x, ...) {
#' @noRd
sort.mic <- function(x, decreasing = FALSE, ...) {
x <- as.mic(x) # make sure that currently implemented MIC levels are used
dbl <- as.double(x)
# make sure that e.g. '<0.001' comes before '0.001', and '>0.001' comes after
dbl[as.character(x) %like% "<[0-9]"] <- dbl[as.character(x) %like% "<[0-9]"] - 0.000002
dbl[as.character(x) %like% "<="] <- dbl[as.character(x) %like% "<="] - 0.000001
dbl[as.character(x) %like% ">="] <- dbl[as.character(x) %like% ">="] + 0.000001
dbl[as.character(x) %like% ">[0-9]"] <- dbl[as.character(x) %like% ">[0-9]"] + 0.000002
if (decreasing == TRUE) {
ord <- order(-as.double(x))
x[order(-dbl)]
} else {
ord <- order(as.double(x))
x[order(dbl)]
}
x[ord]
}
#' @method hist mic

View File

@ -309,7 +309,6 @@ autoplot.mic <- function(object,
breakpoint_type = getOption("AMR_breakpoint_type", "human"),
...) {
stop_ifnot_installed("ggplot2")
object <- as.mic(object) # make sure that currently implemented MIC levels are used
meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE)
meet_criteria(ab, allow_class = c("ab", "character"), allow_NULL = TRUE)
meet_criteria(guideline, allow_class = "character", has_length = 1)
@ -327,6 +326,7 @@ autoplot.mic <- function(object,
title <- gsub(" +", " ", paste0(title, collapse = " "))
}
object <- as.mic(object) # make sure that currently implemented MIC levels are used
x <- range_as_table(object, expand = expand)
cols_sub <- plot_colours_subtitle_guideline(
x = x,

View File

@ -884,6 +884,9 @@ as_sir_method <- function(method_short,
if (length(mo) == 1) {
mo <- rep(mo, length(x))
}
if (length(ab) == 1) {
ab <- rep(ab, length(x))
}
if (is.null(uti)) {
uti <- NA
}

View File

@ -106,7 +106,7 @@ vec_ptype_full.disk <- function(x, ...) {
"disk"
}
vec_ptype_abbr.disk <- function(x, ...) {
"disk"
"dsk"
}
vec_ptype2.disk.default <- function (x, y, ..., x_arg = "", y_arg = "") {
x