mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 21:22:01 +02:00
ggplot2_rsi fix
This commit is contained in:
@ -28,7 +28,7 @@ theme_rsi()
|
||||
\arguments{
|
||||
\item{data}{a \code{data.frame} with column(s) of class \code{"rsi"} (see \code{\link{as.rsi}})}
|
||||
|
||||
\item{position}{position adjustment of bars, either \code{"stack"} (default when \code{fun} is \code{\link{portion_df}}) or \code{"dodge"} (default when \code{fun} is \code{\link{count_df}})}
|
||||
\item{position}{position adjustment of bars, either \code{"fill"}, \code{"stack"} (default when \code{fun} is \code{\link{portion_df}}) or \code{"dodge"} (default when \code{fun} is \code{\link{count_df}})}
|
||||
|
||||
\item{x}{variable to show on x axis, either \code{"Antibiotic"} (default) or \code{"Interpretation"} or a grouping variable}
|
||||
|
||||
@ -75,7 +75,6 @@ ggplot(septic_patients \%>\% select(amox, nitr, fosf, trim, cipr)) +
|
||||
df <- septic_patients[, c("amox", "nitr", "fosf", "trim", "cipr")]
|
||||
ggplot(df) +
|
||||
geom_rsi() +
|
||||
facet_rsi() +
|
||||
scale_y_percent() +
|
||||
scale_rsi_colours() +
|
||||
theme_rsi()
|
||||
@ -106,12 +105,12 @@ septic_patients \%>\%
|
||||
ggplot_rsi() + scale_fill_viridis_d()
|
||||
|
||||
|
||||
# it also supports groups (don't forget to use the group on `x` or `facet`):
|
||||
# it also supports groups (don't forget to use the group var on `x` or `facet`):
|
||||
septic_patients \%>\%
|
||||
select(hospital_id, amox, nitr, fosf, trim, cipr) \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
ggplot_rsi(x = "hospital_id",
|
||||
facet = "Antibiotic",
|
||||
ggplot_rsi(x = hospital_id,
|
||||
facet = Antibiotic,
|
||||
nrow = 1) +
|
||||
labs(title = "AMR of Anti-UTI Drugs Per Hospital",
|
||||
x = "Hospital")
|
||||
@ -120,8 +119,8 @@ septic_patients \%>\%
|
||||
septic_patients \%>\%
|
||||
# create new bacterial ID's, with all CoNS under the same group (Becker et al.)
|
||||
mutate(mo = as.mo(mo, Becker = TRUE)) \%>\%
|
||||
# filter on top 2 bacterial ID's
|
||||
filter(mo \%in\% top_freq(freq(.$mo), 2)) \%>\%
|
||||
# filter on top three bacterial ID's
|
||||
filter(mo \%in\% top_freq(freq(.$mo), 3)) \%>\%
|
||||
# determine first isolates
|
||||
mutate(first_isolate = first_isolate(.,
|
||||
col_date = "date",
|
||||
@ -129,17 +128,18 @@ septic_patients \%>\%
|
||||
col_mo = "mo")) \%>\%
|
||||
# filter on first isolates
|
||||
filter(first_isolate == TRUE) \%>\%
|
||||
# join the `microorganisms` data set
|
||||
left_join_microorganisms() \%>\%
|
||||
# select full name and some antiseptic drugs
|
||||
select(mo = fullname,
|
||||
cfur, gent, cipr) \%>\%
|
||||
# get short MO names (like "E. coli")
|
||||
mutate(mo = mo_shortname(mo, Becker = TRUE)) \%>\%
|
||||
# select this short name and some antiseptic drugs
|
||||
select(mo, cfur, gent, cipr) \%>\%
|
||||
# group by MO
|
||||
group_by(mo) \%>\%
|
||||
# plot the thing, putting MOs on the facet
|
||||
ggplot_rsi(x = "Antibiotic",
|
||||
facet = "mo") +
|
||||
labs(title = "AMR of Top Two Microorganisms In Blood Culture Isolates",
|
||||
ggplot_rsi(x = Antibiotic,
|
||||
facet = mo,
|
||||
translate_ab = FALSE,
|
||||
nrow = 1) +
|
||||
labs(title = "AMR of Top Three Microorganisms In Blood Culture Isolates",
|
||||
subtitle = "Only First Isolates, CoNS grouped according to Becker et al. (2014)",
|
||||
x = "Microorganisms")
|
||||
}
|
||||
|
Reference in New Issue
Block a user