mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 08:32:04 +02:00
(v1.1.0.9007) lose dependencies
This commit is contained in:
@ -38,6 +38,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
||||
}
|
||||
|
||||
\examples{
|
||||
\dontrun{
|
||||
# transform existing disk zones to the `disk` class
|
||||
library(dplyr)
|
||||
df <- data.frame(microorganism = "E. coli",
|
||||
@ -56,6 +57,7 @@ as.rsi(x = as.disk(18),
|
||||
|
||||
as.rsi(df)
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=as.rsi]{as.rsi()}}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ df <- data.frame(microorganism = "E. coli",
|
||||
NIT = as.mic(32))
|
||||
as.rsi(df)
|
||||
|
||||
\donttest{
|
||||
\dontrun{
|
||||
|
||||
# the dplyr way
|
||||
library(dplyr)
|
||||
@ -157,6 +157,7 @@ is.rsi(rsi_data)
|
||||
plot(rsi_data) # for percentages
|
||||
barplot(rsi_data) # for frequencies
|
||||
|
||||
\dontrun{
|
||||
library(dplyr)
|
||||
example_isolates \%>\%
|
||||
mutate_at(vars(PEN:RIF), as.rsi)
|
||||
@ -173,6 +174,7 @@ example_isolates \%>\%
|
||||
is.rsi.eligible(WHONET$`First name`) # fails, >80\% is invalid
|
||||
is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=as.mic]{as.mic()}}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
||||
}
|
||||
|
||||
\examples{
|
||||
\donttest{
|
||||
\dontrun{
|
||||
# oral DDD (Defined Daily Dose) of amoxicillin
|
||||
atc_online_property("J01CA04", "DDD", "O")
|
||||
# parenteral DDD (Defined Daily Dose) of amoxicillin
|
||||
|
@ -36,6 +36,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
||||
\examples{
|
||||
availability(example_isolates)
|
||||
|
||||
\dontrun{
|
||||
library(dplyr)
|
||||
example_isolates \%>\% availability()
|
||||
|
||||
@ -48,3 +49,4 @@ example_isolates \%>\%
|
||||
select_if(is.rsi) \%>\%
|
||||
availability()
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ count_susceptible(example_isolates$AMX)
|
||||
susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
|
||||
|
||||
|
||||
if (!require("dplyr")) {
|
||||
if (require("dplyr")) {
|
||||
example_isolates \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(R = count_R(CIP),
|
||||
|
@ -147,44 +147,45 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
||||
}
|
||||
|
||||
\examples{
|
||||
library(dplyr)
|
||||
library(ggplot2)
|
||||
|
||||
# get antimicrobial results for drugs against a UTI:
|
||||
ggplot(example_isolates \%>\% select(AMX, NIT, FOS, TMP, CIP)) +
|
||||
geom_rsi()
|
||||
|
||||
# prettify the plot using some additional functions:
|
||||
df <- example_isolates \%>\% select(AMX, NIT, FOS, TMP, CIP)
|
||||
ggplot(df) +
|
||||
geom_rsi() +
|
||||
scale_y_percent() +
|
||||
scale_rsi_colours() +
|
||||
labels_rsi_count() +
|
||||
theme_rsi()
|
||||
|
||||
# or better yet, simplify this using the wrapper function - a single command:
|
||||
example_isolates \%>\%
|
||||
select(AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
ggplot_rsi()
|
||||
|
||||
# get only proportions and no counts:
|
||||
example_isolates \%>\%
|
||||
select(AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
ggplot_rsi(datalabels = FALSE)
|
||||
|
||||
# add other ggplot2 parameters as you like:
|
||||
example_isolates \%>\%
|
||||
select(AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
ggplot_rsi(width = 0.5,
|
||||
colour = "black",
|
||||
size = 1,
|
||||
linetype = 2,
|
||||
alpha = 0.25)
|
||||
|
||||
example_isolates \%>\%
|
||||
select(AMX) \%>\%
|
||||
ggplot_rsi(colours = c(SI = "yellow"))
|
||||
if (require("ggplot2") & require("dplyr")) {
|
||||
|
||||
# get antimicrobial results for drugs against a UTI:
|
||||
ggplot(example_isolates \%>\% select(AMX, NIT, FOS, TMP, CIP)) +
|
||||
geom_rsi()
|
||||
|
||||
# prettify the plot using some additional functions:
|
||||
df <- example_isolates \%>\% select(AMX, NIT, FOS, TMP, CIP)
|
||||
ggplot(df) +
|
||||
geom_rsi() +
|
||||
scale_y_percent() +
|
||||
scale_rsi_colours() +
|
||||
labels_rsi_count() +
|
||||
theme_rsi()
|
||||
|
||||
# or better yet, simplify this using the wrapper function - a single command:
|
||||
example_isolates \%>\%
|
||||
select(AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
ggplot_rsi()
|
||||
|
||||
# get only proportions and no counts:
|
||||
example_isolates \%>\%
|
||||
select(AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
ggplot_rsi(datalabels = FALSE)
|
||||
|
||||
# add other ggplot2 parameters as you like:
|
||||
example_isolates \%>\%
|
||||
select(AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
ggplot_rsi(width = 0.5,
|
||||
colour = "black",
|
||||
size = 1,
|
||||
linetype = 2,
|
||||
alpha = 0.25)
|
||||
|
||||
example_isolates \%>\%
|
||||
select(AMX) \%>\%
|
||||
ggplot_rsi(colours = c(SI = "yellow"))
|
||||
|
||||
}
|
||||
|
||||
\dontrun{
|
||||
|
||||
|
@ -136,6 +136,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
||||
# `example_isolates` is a dataset available in the AMR package.
|
||||
# See ?example_isolates.
|
||||
|
||||
\dontrun{
|
||||
library(dplyr)
|
||||
# set key antibiotics to a new variable
|
||||
my_patients <- example_isolates \%>\%
|
||||
@ -150,7 +151,7 @@ my_patients <- example_isolates \%>\%
|
||||
# Check the difference, in this data set it results in 7\% more isolates:
|
||||
sum(my_patients$first_regular, na.rm = TRUE)
|
||||
sum(my_patients$first_weighted, na.rm = TRUE)
|
||||
|
||||
}
|
||||
|
||||
# output of the `key_antibiotics` function could be like this:
|
||||
strainA <- "SSSRR.S.R..S"
|
||||
|
@ -68,11 +68,13 @@ a \%like\% b
|
||||
#> TRUE TRUE TRUE
|
||||
|
||||
# get isolates whose name start with 'Ent' or 'ent'
|
||||
\dontrun{
|
||||
library(dplyr)
|
||||
example_isolates \%>\%
|
||||
filter(mo_name(mo) \%like\% "^ent") \%>\%
|
||||
freq(mo)
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[base:grep]{base::grep()}}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
||||
}
|
||||
|
||||
\examples{
|
||||
\donttest{
|
||||
\dontrun{
|
||||
library(dplyr)
|
||||
|
||||
example_isolates \%>\%
|
||||
|
@ -160,8 +160,7 @@ proportion_I(example_isolates$AMX)
|
||||
proportion_IR(example_isolates$AMX)
|
||||
proportion_R(example_isolates$AMX)
|
||||
|
||||
if (!require("dplyr")) {
|
||||
library(dplyr)
|
||||
if (require("dplyr")) {
|
||||
example_isolates \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(r = resistance(CIP),
|
||||
@ -218,7 +217,9 @@ if (!require("dplyr")) {
|
||||
select(hospital_id, AMX, CIP) \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
proportion_df(translate = FALSE)
|
||||
|
||||
}
|
||||
|
||||
\dontrun{
|
||||
# calculate current empiric combination therapy of Helicobacter gastritis:
|
||||
my_table \%>\%
|
||||
filter(first_isolate == TRUE,
|
||||
|
@ -132,11 +132,12 @@ x <- resistance_predict(example_isolates,
|
||||
year_min = 2010,
|
||||
model = "binomial")
|
||||
plot(x)
|
||||
ggplot_rsi_predict(x)
|
||||
if (require("ggplot2")) {
|
||||
ggplot_rsi_predict(x)
|
||||
}
|
||||
|
||||
# using dplyr:
|
||||
if (!require("dplyr")) {
|
||||
library(dplyr)
|
||||
if (require("dplyr")) {
|
||||
x <- example_isolates \%>\%
|
||||
filter_first_isolate() \%>\%
|
||||
filter(mo_genus(mo) == "Staphylococcus") \%>\%
|
||||
@ -149,7 +150,7 @@ if (!require("dplyr")) {
|
||||
}
|
||||
|
||||
# create nice plots with ggplot2 yourself
|
||||
if (!require(ggplot2) & !require("dplyr")) {
|
||||
if (require(ggplot2) & require("dplyr")) {
|
||||
|
||||
data <- example_isolates \%>\%
|
||||
filter(mo == as.mo("E. coli")) \%>\%
|
||||
|
Reference in New Issue
Block a user