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:
@ -889,6 +889,7 @@ eucast_rules <- function(x,
|
||||
),
|
||||
type = "ansi"
|
||||
))
|
||||
cat("\n")
|
||||
warned <- FALSE
|
||||
}
|
||||
run_changes <- edit_sir(
|
||||
|
11
R/mic.R
11
R/mic.R
@ -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
|
||||
|
2
R/plot.R
2
R/plot.R
@ -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,
|
||||
|
3
R/sir.R
3
R/sir.R
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user