1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 16:42:10 +02:00

(v1.1.0.9006) lose dependencies

This commit is contained in:
2020-05-16 20:42:45 +02:00
parent df2456b91f
commit 29609a0e2c
8 changed files with 109 additions and 86 deletions

View File

@ -63,16 +63,14 @@ filter_join_worker <- function(x, y, by = NULL, type = c("anti", "semi")) {
# No export, no Rd
addin_insert_in <- function() {
if (!require("rstudioapi")) {
insertText(" %in% ")
}
stopifnot_installed_package("rstudioapi")
get("insertText", envir = asNamespace("rstudioapi"))(" %in% ")
}
# No export, no Rd
addin_insert_like <- function() {
if (!require("rstudioapi")) {
insertText(" %like% ")
}
stopifnot_installed_package("rstudioapi")
get("insertText", envir = asNamespace("rstudioapi"))(" %like% ")
}
check_dataset_integrity <- function() {

View File

@ -59,7 +59,7 @@
#' @inheritSection AMR Read more on our website!
#' @source <https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/>
#' @examples
#' \donttest{
#' \dontrun{
#' # oral DDD (Defined Daily Dose) of amoxicillin
#' atc_online_property("J01CA04", "DDD", "O")
#' # parenteral DDD (Defined Daily Dose) of amoxicillin
@ -77,6 +77,14 @@ atc_online_property <- function(atc_code,
url = "https://www.whocc.no/atc_ddd_index/?code=%s&showdescription=no") {
stopifnot_installed_package(c("curl", "rvest", "xml2"))
has_internet <- get("has_internet", envir = asNamespace("curl"))
html_attr <- get("html_attr", envir = asNamespace("rvest"))
html_children <- get("html_children", envir = asNamespace("rvest"))
html_node <- get("html_node", envir = asNamespace("rvest"))
html_nodes <- get("html_nodes", envir = asNamespace("rvest"))
html_table <- get("html_table", envir = asNamespace("rvest"))
html_text <- get("html_text", envir = asNamespace("rvest"))
read_html <- get("read_html", envir = asNamespace("xml2"))
check_dataset_integrity()
@ -84,10 +92,6 @@ atc_online_property <- function(atc_code,
atc_code <- as.character(ab_atc(atc_code))
}
require("curl")
require("xml2")
require("rvest")
if (!has_internet()) {
message("There appears to be no internet connection.")
return(rep(NA, length(atc_code)))

View File

@ -62,44 +62,45 @@
#' @export
#' @inheritSection AMR Read more on our website!
#' @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{
#'