# transform existing disk zones to the `disk` class +@@ -353,7 +353,7 @@ The lifecycle of this function is stableNIT = as.mic(32)) as.rsi(df) -# \donttest{ +if (FALSE) { # the dplyr way library(dplyr) @@ -376,7 +376,7 @@ The lifecycle of this function is stabledf %>% mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE) -# } +} # for single values as.rsi(x = as.mic(2), @@ -400,6 +400,7 @@ The lifecycle of this function is stableplot(rsi_data) # for percentages barplot(rsi_data) # for frequencies +if (FALSE) { library(dplyr) example_isolates %>% mutate_at(vars(PEN:RIF), as.rsi) @@ -414,7 +415,8 @@ The lifecycle of this function is stable# default threshold of `is.rsi.eligible` is 5%. is.rsi.eligible(WHONET$`First name`) # fails, >80% is invalid -is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds +is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds +} @@ -315,7 +315,7 @@ The lifecycle of this function is questioniif (FALSE) { +# transform existing disk zones to the `disk` class library(dplyr) df <- data.frame(microorganism = "E. coli", AMP = 20, @@ -291,7 +292,8 @@ The lifecycle of this function is stableab = "ampicillin", # and `ab` with as.ab() guideline = "EUCAST") -as.rsi(df)+as.rsi(df) +}
On our website https://msberends.gitlab.io/AMR you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data.
# \donttest{ +diff --git a/docs/reference/availability.html b/docs/reference/availability.html index 98bd0c47..89e6340a 100644 --- a/docs/reference/availability.html +++ b/docs/reference/availability.html @@ -82,7 +82,7 @@ @@ -272,6 +272,7 @@ The lifecycle of this function is stableExamplesif (FALSE) { # oral DDD (Defined Daily Dose) of amoxicillin atc_online_property("J01CA04", "DDD", "O") # parenteral DDD (Defined Daily Dose) of amoxicillin @@ -326,7 +326,7 @@ The lifecycle of this function is questioni # [2] "ANTIBACTERIALS FOR SYSTEMIC USE" # [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS" # [4] "Penicillins with extended spectrum" -# }+}
availability(example_isolates) +if (FALSE) { library(dplyr) example_isolates %>% availability() @@ -282,7 +283,8 @@ The lifecycle of this function is stableexample_isolates %>% filter(mo == as.mo("E. coli")) %>% select_if(is.rsi) %>% - availability()+ availability() +} @@ -392,7 +392,7 @@ A microorganism is categorised as Susceptible, Increased exposure when 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), diff --git a/docs/reference/ggplot_rsi.html b/docs/reference/ggplot_rsi.html index f15eaccd..be325a91 100644 --- a/docs/reference/ggplot_rsi.html +++ b/docs/reference/ggplot_rsi.html @@ -82,7 +82,7 @@ @@ -412,44 +412,45 @@ The lifecycle of this function is maturing<
On our website https://msberends.gitlab.io/AMR you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data.
library(dplyr) -library(ggplot2) +@@ -440,7 +440,7 @@ A microorganism is categorised as Susceptible, Increased exposure whenif (require("ggplot2") & require("dplyr")) { -# get antimicrobial results for drugs against a UTI: -ggplot(example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)) + - geom_rsi() + # 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() + # 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() + # 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) + # 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) + # 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")) + example_isolates %>% + select(AMX) %>% + ggplot_rsi(colours = c(SI = "yellow")) + +} if (FALSE) { diff --git a/docs/reference/index.html b/docs/reference/index.html index d170852e..588d7cec 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index 5e095227..7ca2c6f6 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -82,7 +82,7 @@ @@ -388,6 +388,7 @@ The lifecycle of this function is stable# `example_isolates` is a dataset available in the AMR package. # See ?example_isolates. +if (FALSE) { library(dplyr) # set key antibiotics to a new variable my_patients <- example_isolates %>% @@ -402,7 +403,7 @@ The lifecycle of this function is stable# 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" diff --git a/docs/reference/like.html b/docs/reference/like.html index 642fe0c1..2f43bd6e 100644 --- a/docs/reference/like.html +++ b/docs/reference/like.html @@ -82,7 +82,7 @@ @@ -306,10 +306,12 @@ The lifecycle of this function is stable#> TRUE TRUE TRUE # get isolates whose name start with 'Ent' or 'ent' +if (FALSE) { library(dplyr) example_isolates %>% filter(mo_name(mo) %like% "^ent") %>% - freq(mo)+ freq(mo) +}
On our website https://msberends.gitlab.io/AMR you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data.
# \donttest{ +@@ -398,8 +398,7 @@ A microorganism is categorised as Susceptible, Increased exposure when 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), @@ -456,7 +455,9 @@ A microorganism is categorised as Susceptible, Increased exposure when select(hospital_id, AMX, CIP) %>% group_by(hospital_id) %>% proportion_df(translate = FALSE) +} +if (FALSE) { # calculate current empiric combination therapy of Helicobacter gastritis: my_table %>% filter(first_isolate == TRUE, diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index 509a0112..f8eebe60 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -82,7 +82,7 @@ @@ -393,11 +393,12 @@ A microorganism is categorised as Susceptible, Increased exposure when 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") %>% @@ -410,7 +411,7 @@ A microorganism is categorised as Susceptible, Increased exposure when } # 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")) %>% diff --git a/man/as.disk.Rd b/man/as.disk.Rd index b9314e2e..139789d1 100644 --- a/man/as.disk.Rd +++ b/man/as.disk.Rd @@ -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()}} } diff --git a/man/as.rsi.Rd b/man/as.rsi.Rd index 3b12605b..22f99c0d 100755 --- a/man/as.rsi.Rd +++ b/man/as.rsi.Rd @@ -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()}} } diff --git a/man/atc_online.Rd b/man/atc_online.Rd index 9be89d9c..41752155 100644 --- a/man/atc_online.Rd +++ b/man/atc_online.Rd @@ -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 diff --git a/man/availability.Rd b/man/availability.Rd index 8edf15e6..325a4d68 100644 --- a/man/availability.Rd +++ b/man/availability.Rd @@ -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() } +} diff --git a/man/count.Rd b/man/count.Rd index 1561ed6e..2a818413 100644 --- a/man/count.Rd +++ b/man/count.Rd @@ -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), diff --git a/man/ggplot_rsi.Rd b/man/ggplot_rsi.Rd index e1b907f8..c1d45b31 100644 --- a/man/ggplot_rsi.Rd +++ b/man/ggplot_rsi.Rd @@ -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{ diff --git a/man/key_antibiotics.Rd b/man/key_antibiotics.Rd index 8a2b5352..b01058a4 100755 --- a/man/key_antibiotics.Rd +++ b/man/key_antibiotics.Rd @@ -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" diff --git a/man/like.Rd b/man/like.Rd index 818ca122..80b4a4ec 100755 --- a/man/like.Rd +++ b/man/like.Rd @@ -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()}} } diff --git a/man/mdro.Rd b/man/mdro.Rd index a7f3e9be..e66d875c 100644 --- a/man/mdro.Rd +++ b/man/mdro.Rd @@ -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 \%>\% diff --git a/man/proportion.Rd b/man/proportion.Rd index f79edfb4..0d6e884a 100644 --- a/man/proportion.Rd +++ b/man/proportion.Rd @@ -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, diff --git a/man/resistance_predict.Rd b/man/resistance_predict.Rd index 6b4d159e..fcb0268a 100644 --- a/man/resistance_predict.Rd +++ b/man/resistance_predict.Rd @@ -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")) \%>\%if (FALSE) { library(dplyr) example_isolates %>% @@ -451,7 +451,7 @@ A microorganism is categorised as Susceptible, Increased exposure when mutate(EUCAST = eucast_exceptional_phenotypes(.), BRMO = brmo(.), MRGN = mrgn(.)) -# }+}