diff --git a/DESCRIPTION b/DESCRIPTION index c41350f4..935943e7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.1.0.9006 +Version: 1.1.0.9007 Date: 2020-05-16 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index ee4e81ae..c432f1dc 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.1.0.9006 +# AMR 1.1.0.9007 ## Last updated: 16-May-2020 ### Breaking diff --git a/R/availability.R b/R/availability.R index c7c16cfb..91acae5a 100644 --- a/R/availability.R +++ b/R/availability.R @@ -32,6 +32,7 @@ #' @examples #' availability(example_isolates) #' +#' \dontrun{ #' library(dplyr) #' example_isolates %>% availability() #' @@ -43,6 +44,7 @@ #' filter(mo == as.mo("E. coli")) %>% #' select_if(is.rsi) %>% #' availability() +#' } availability <- function(tbl, width = NULL) { x <- base::sapply(tbl, function(x) { 1 - base::sum(base::is.na(x)) / base::length(x) diff --git a/R/count.R b/R/count.R index db56c254..3b4603e6 100755 --- a/R/count.R +++ b/R/count.R @@ -69,7 +69,7 @@ #' 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/R/disk.R b/R/disk.R index 2ceed22c..9b7229cf 100644 --- a/R/disk.R +++ b/R/disk.R @@ -33,6 +33,7 @@ #' @seealso [as.rsi()] #' @inheritSection AMR Read more on our website! #' @examples +#' \dontrun{ #' # transform existing disk zones to the `disk` class #' library(dplyr) #' df <- data.frame(microorganism = "E. coli", @@ -50,6 +51,7 @@ #' guideline = "EUCAST") #' #' as.rsi(df) +#' } as.disk <- function(x, na.rm = FALSE) { if (is.disk(x)) { x diff --git a/R/eucast_rules.R b/R/eucast_rules.R index fe9bc96b..5cc7293a 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -206,7 +206,8 @@ eucast_rules <- function(x, "\n\nThis may overwrite your existing data if you use e.g.:", "\ndata <- eucast_rules(data, verbose = TRUE)\n\nDo you want to continue?") if ("rstudioapi" %in% rownames(utils::installed.packages())) { - q_continue <- rstudioapi::showQuestion("Using verbose = TRUE with eucast_rules()", txt) + showQuestion <- get("showQuestion", envir = asNamespace("rstudioapi")) + q_continue <- showQuestion("Using verbose = TRUE with eucast_rules()", txt) } else { q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt) } diff --git a/R/ggplot_rsi.R b/R/ggplot_rsi.R index 2b3280aa..fb80dae3 100755 --- a/R/ggplot_rsi.R +++ b/R/ggplot_rsi.R @@ -62,7 +62,7 @@ #' @export #' @inheritSection AMR Read more on our website! #' @examples -#' if (!require("ggplot2") & !require("dplyr")) { +#' if (require("ggplot2") & require("dplyr")) { #' #' # get antimicrobial results for drugs against a UTI: #' ggplot(example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)) + diff --git a/R/key_antibiotics.R b/R/key_antibiotics.R index 0632ca2a..9dc7c233 100755 --- a/R/key_antibiotics.R +++ b/R/key_antibiotics.R @@ -73,6 +73,7 @@ #' # `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 %>% @@ -87,7 +88,7 @@ #' # 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/R/like.R b/R/like.R index 467a8c2d..42e7a6cb 100755 --- a/R/like.R +++ b/R/like.R @@ -57,10 +57,12 @@ #' #> 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) +#' } like <- function(x, pattern, ignore.case = TRUE) { # set to fixed if no regex found fixed <- all(!grepl("[$.^*?+}{|)(]", pattern)) diff --git a/R/mdro.R b/R/mdro.R index 63523984..adac0965 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -66,7 +66,7 @@ #' @source #' Please see *Details* for the list of publications used for this function. #' @examples -#' \donttest{ +#' \dontrun{ #' library(dplyr) #' #' example_isolates %>% @@ -94,7 +94,8 @@ mdro <- function(x, "\n\nThis may overwrite your existing data if you use e.g.:", "\ndata <- mdro(data, verbose = TRUE)\n\nDo you want to continue?") if ("rstudioapi" %in% rownames(utils::installed.packages())) { - q_continue <- rstudioapi::showQuestion("Using verbose = TRUE with mdro()", txt) + showQuestion <- get("showQuestion", envir = asNamespace("rstudioapi")) + q_continue <- showQuestion("Using verbose = TRUE with mdro()", txt) } else { q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt) } diff --git a/R/mo_source.R b/R/mo_source.R index 3909762f..b44b79d4 100644 --- a/R/mo_source.R +++ b/R/mo_source.R @@ -126,7 +126,8 @@ set_mo_source <- function(path) { } else if (path %like% "[.]xlsx?$") { # is Excel file (old or new) stopifnot_installed_package("readxl") - df <- readxl::read_excel(path) + read_excel <- get("read_excel", envir = asNamespace("readxl")) + df <- read_excel(path) } else if (path %like% "[.]tsv$") { df <- utils::read.table(header = TRUE, sep = "\t", stringsAsFactors = FALSE) diff --git a/R/proportion.R b/R/proportion.R index b2d138ba..04547902 100755 --- a/R/proportion.R +++ b/R/proportion.R @@ -99,8 +99,7 @@ #' 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), @@ -157,7 +156,9 @@ #' 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/R/resistance_predict.R b/R/resistance_predict.R index 6459c3a7..b9f223d6 100755 --- a/R/resistance_predict.R +++ b/R/resistance_predict.R @@ -66,11 +66,12 @@ #' 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") %>% @@ -83,7 +84,7 @@ #' } #' #' # 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/R/rsi.R b/R/rsi.R index 3355b4c8..ac4a18b2 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -70,7 +70,7 @@ #' NIT = as.mic(32)) #' as.rsi(df) #' -#' \donttest{ +#' \dontrun{ #' #' # the dplyr way #' library(dplyr) @@ -117,6 +117,7 @@ #' plot(rsi_data) # for percentages #' barplot(rsi_data) # for frequencies #' +#' \dontrun{ #' library(dplyr) #' example_isolates %>% #' mutate_at(vars(PEN:RIF), as.rsi) @@ -132,6 +133,7 @@ #' # 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 +#' } as.rsi <- function(x, ...) { UseMethod("as.rsi") } diff --git a/appveyor.yml b/appveyor.yml index 04de586a..8c03bc80 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,7 +23,7 @@ init: ps: | $ErrorActionPreference = "Stop" - Invoke-WebRequest https://gitlab.com/msberends/AMR/raw/master/tests/appveyor/appveyor_tool.ps1 -OutFile "..\appveyor-tool.ps1" + Invoke-WebRequest https://gitlab.com/msberends/AMR/raw/premaster/tests/appveyor/appveyor_tool.ps1 -OutFile "..\appveyor-tool.ps1" Import-Module '..\appveyor-tool.ps1' install: diff --git a/docs/404.html b/docs/404.html index 0383d297..ec79042f 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9005 + 1.1.0.9007 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 1c069be9..d45e92a8 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9005 + 1.1.0.9007 diff --git a/docs/articles/index.html b/docs/articles/index.html index ccc199d4..1ee6d8f2 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9005 + 1.1.0.9007 diff --git a/docs/authors.html b/docs/authors.html index f8712280..d885217b 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9005 + 1.1.0.9007 diff --git a/docs/index.html b/docs/index.html index 10189d5a..7b9ea364 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.1.0.9005 + 1.1.0.9007 diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index a75bf77c..69be2641 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -10,7 +10,7 @@ articles: WHONET: WHONET.html benchmarks: benchmarks.html resistance_predict: resistance_predict.html -last_built: 2020-05-16T18:05Z +last_built: 2020-05-16T19:39Z urls: reference: https://msberends.gitlab.io/AMR/reference article: https://msberends.gitlab.io/AMR/articles diff --git a/docs/reference/as.disk.html b/docs/reference/as.disk.html index 23a00948..723ef647 100644 --- a/docs/reference/as.disk.html +++ b/docs/reference/as.disk.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0 + 1.1.0.9007 @@ -275,7 +275,8 @@ The lifecycle of this function is stable

as.rsi()

Examples

-
# transform existing disk zones to the `disk` class
+    
if (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) +}
@@ -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 questioni

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.

Examples

-
# \donttest{
+    
if (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"
-# }
+}
-

Site built with pkgdown 1.5.0.

+

Site built with pkgdown 1.5.1.

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 @@ AMR (for R) - 1.1.0 + 1.1.0.9007 @@ -272,6 +272,7 @@ The lifecycle of this function is stableExamples
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 @@ AMR (for R) - 1.1.0.9004 + 1.1.0.9007 @@ -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.

Examples

-
library(dplyr)
-library(ggplot2)
+    
if (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 @@
       
       
         AMR (for R)
-        1.1.0.9005
+        1.1.0.9007
       
     
 
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 @@
       
       
         AMR (for R)
-        1.1.0.9004
+        1.1.0.9007
       
     
 
@@ -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 @@
       
       
         AMR (for R)
-        1.1.0.9004
+        1.1.0.9007
       
     
 
@@ -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) +}
@@ -440,7 +440,7 @@ A microorganism is categorised as Susceptible, Increased exposure when

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.

Examples

-
# \donttest{
+    
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(.))
-# }
+}
@@ -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 @@ AMR (for R) - 1.1.0.9004 + 1.1.0.9007 @@ -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")) \%>\%