mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 20:06:11 +01:00
autoplot fix
This commit is contained in:
parent
d4490c7f25
commit
ba4dc20cf3
@ -1,5 +1,5 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 2.1.1.9034
|
Version: 2.1.1.9035
|
||||||
Date: 2024-05-30
|
Date: 2024-05-30
|
||||||
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)
|
||||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
|||||||
# AMR 2.1.1.9034
|
# AMR 2.1.1.9035
|
||||||
|
|
||||||
*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support!)*
|
*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support!)*
|
||||||
|
|
||||||
|
5
R/plot.R
5
R/plot.R
@ -760,9 +760,10 @@ autoplot.sir <- function(object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
df <- as.data.frame(table(object), stringsAsFactors = TRUE)
|
df <- as.data.frame(table(object), stringsAsFactors = TRUE)
|
||||||
colnames(df) <- c("sir", "count")
|
colnames(df) <- c("x", "n")
|
||||||
|
df <- df[!(df$n == 0 & df$x %in% c("SDD", "I", "N")), , drop = FALSE]
|
||||||
ggplot2::ggplot(df) +
|
ggplot2::ggplot(df) +
|
||||||
ggplot2::geom_col(ggplot2::aes(x = sir, y = count, fill = sir)) +
|
ggplot2::geom_col(ggplot2::aes(x = x, y = n, fill = x)) +
|
||||||
# limits = force is needed because of a ggplot2 >= 3.3.4 bug (#4511)
|
# limits = force is needed because of a ggplot2 >= 3.3.4 bug (#4511)
|
||||||
ggplot2::scale_fill_manual(
|
ggplot2::scale_fill_manual(
|
||||||
values = c(
|
values = c(
|
||||||
|
12
R/sir.R
12
R/sir.R
@ -907,15 +907,15 @@ as_sir_method <- function(method_short,
|
|||||||
same_ab <- generalise_antibiotic_name(ab) == generalise_antibiotic_name(agent_name)
|
same_ab <- generalise_antibiotic_name(ab) == generalise_antibiotic_name(agent_name)
|
||||||
same_ab.bak <- generalise_antibiotic_name(ab.bak) == generalise_antibiotic_name(agent_name)
|
same_ab.bak <- generalise_antibiotic_name(ab.bak) == generalise_antibiotic_name(agent_name)
|
||||||
agent_formatted[same_ab.bak] <- paste0(agent_formatted[same_ab.bak], " (", ab, ")")
|
agent_formatted[same_ab.bak] <- paste0(agent_formatted[same_ab.bak], " (", ab, ")")
|
||||||
agent_formatted[same_ab.bak & !same_ab] <- paste0(agent_formatted[same_ab.bak & !same_ab],
|
agent_formatted[!same_ab.bak & !same_ab] <- paste0(agent_formatted[!same_ab.bak & !same_ab],
|
||||||
" (", ifelse(ab.bak[same_ab.bak & !same_ab] == ab[same_ab.bak & !same_ab],
|
" (", ifelse(ab.bak[!same_ab.bak & !same_ab] == ab[!same_ab.bak & !same_ab],
|
||||||
"",
|
"",
|
||||||
paste0(ab[same_ab.bak & !same_ab], ", ")),
|
paste0(ab[!same_ab.bak & !same_ab], ", ")),
|
||||||
agent_name[same_ab.bak & !same_ab],
|
agent_name[!same_ab.bak & !same_ab],
|
||||||
")")
|
")")
|
||||||
# this intro text will also be printed in the progress bar in the `progress` package is installed
|
# this intro text will also be printed in the progress bar if the `progress` package is installed
|
||||||
intro_txt <- paste0("Interpreting ", method_long, ": ", ifelse(isTRUE(list(...)$is_data.frame), "column ", ""),
|
intro_txt <- paste0("Interpreting ", method_long, ": ", ifelse(isTRUE(list(...)$is_data.frame), "column ", ""),
|
||||||
ifelse(length(agent_formatted) == 1, agent_formatted, ""),
|
ifelse(length(unique(agent_formatted)) == 1, unique(agent_formatted), vector_and(ab, quotes = FALSE)),
|
||||||
mo_var_found,
|
mo_var_found,
|
||||||
ifelse(identical(reference_data, AMR::clinical_breakpoints),
|
ifelse(identical(reference_data, AMR::clinical_breakpoints),
|
||||||
paste0(", ", font_bold(guideline_coerced)),
|
paste0(", ", font_bold(guideline_coerced)),
|
||||||
|
Loading…
Reference in New Issue
Block a user