1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 02:03:04 +02:00

(v1.6.0.9063) prepare new release

This commit is contained in:
2021-05-24 09:00:11 +02:00
parent 06302d296a
commit a13fd98e8b
64 changed files with 157 additions and 107 deletions

3
R/ab.R
View File

@ -82,7 +82,7 @@
#' # they use as.ab() internally:
#' ab_name("J01FA01") # "Erythromycin"
#' ab_name("eryt") # "Erythromycin"
#'
#' \donttest{
#' if (require("dplyr")) {
#'
#' # you can quickly rename <rsi> columns using dplyr >= 1.0.0:
@ -90,6 +90,7 @@
#' rename_with(as.ab, where(is.rsi))
#'
#' }
#' }
as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
meet_criteria(x, allow_class = c("character", "numeric", "integer", "factor"), allow_NA = TRUE)
meet_criteria(flag_multiple_results, allow_class = "logical", has_length = 1)

View File

@ -70,7 +70,7 @@
#'
#'
#' # dplyr -------------------------------------------------------------------
#'
#' \donttest{
#' if (require("dplyr")) {
#'
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
@ -119,6 +119,7 @@
#' example_isolates %>% filter(carbapenems() == "R")
#' example_isolates %>% filter(across(carbapenems(), ~.x == "R"))
#' }
#' }
ab_class <- function(ab_class,
only_rsi_columns = FALSE) {
ab_selector(ab_class, function_name = "ab_class", only_rsi_columns = only_rsi_columns)

View File

@ -88,13 +88,13 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) {
# add decimal parts of year
mod <- n_days_x_rest / n_days_reference_year
# negative mods are cases where `x_in_reference_year` > `reference` - so 'add' a year
mod[mod < 0] <- mod[mod < 0] + 1
mod[!is.na(mod) & mod < 0] <- mod[!is.na(mod) & mod < 0] + 1
# and finally add to ages
ages <- ages + mod
}
if (any(ages < 0, na.rm = TRUE)) {
ages[ages < 0] <- NA
ages[!is.na(ages) & ages < 0] <- NA
warning_("NAs introduced for ages below 0.", call = TRUE)
}
if (any(ages > 120, na.rm = TRUE)) {

View File

@ -64,7 +64,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")
#'

View File

@ -35,13 +35,14 @@
#' @export
#' @examples
#' availability(example_isolates)
#'
#' \donttest{
#' if (require("dplyr")) {
#' example_isolates %>%
#' filter(mo == as.mo("E. coli")) %>%
#' select_if(is.rsi) %>%
#' availability()
#' }
#' }
availability <- function(tbl, width = NULL) {
meet_criteria(tbl, allow_class = "data.frame")
meet_criteria(width, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE, is_positive = TRUE, is_finite = TRUE)

View File

@ -72,7 +72,7 @@
#' count_susceptible(example_isolates$AMX)
#' susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
#'
#'
#' \donttest{
#' if (require("dplyr")) {
#' example_isolates %>%
#' group_by(hospital_id) %>%
@ -106,6 +106,7 @@
#' group_by(hospital_id) %>%
#' count_df(translate = FALSE)
#' }
#' }
count_resistant <- function(..., only_all_tested = FALSE) {
rsi_calc(...,
ab_result = "R",

View File

@ -269,12 +269,14 @@
#' @inheritSection AMR Reference Data Publicly Available
#' @inheritSection AMR Read more on Our Website!
#' @examples
#' \donttest{
#' if (require("dplyr")) {
#' intrinsic_resistant %>%
#' filter(antibiotic == "Vancomycin", microorganism %like% "Enterococcus") %>%
#' pull(microorganism)
#' # [1] "Enterococcus casseliflavus" "Enterococcus gallinarum"
#' }
#' }
"intrinsic_resistant"
#' Data Set with Treatment Dosages as Defined by EUCAST

View File

@ -65,6 +65,7 @@
#' # See ?example_isolates.
#'
#' # See ?pca for more info about Principal Component Analysis (PCA).
#' \donttest{
#' if (require("dplyr")) {
#' pca_model <- example_isolates %>%
#' filter(mo_genus(mo) == "Staphylococcus") %>%
@ -84,6 +85,7 @@
#' labs(title = "Title here")
#' }
#' }
#' }
ggplot_pca <- function(x,
choices = 1:2,
scale = 1,

View File

@ -67,6 +67,7 @@
#' @export
#' @inheritSection AMR Read more on Our Website!
#' @examples
#' \donttest{
#' if (require("ggplot2") & require("dplyr")) {
#'
#' # get antimicrobial results for drugs against a UTI:
@ -116,7 +117,6 @@
#' scale_rsi_colours(Value4 = "S", Value5 = "I", Value6 = "R")
#' }
#'
#' \donttest{
#' # resistance of ciprofloxacine per age group
#' example_isolates %>%
#' mutate(first_isolate = first_isolate(.)) %>%

View File

@ -45,12 +45,13 @@
#'
#' # since ggplot2 supports no markdown (yet), use
#' # italicise_taxonomy() and the `ggtext` pkg for titles:
#'
#' \donttest{
#' if (require("ggplot2") && require("ggtext")) {
#' ggplot(example_isolates$AMC,
#' title = italicise_taxonomy("Amoxi/clav in E. coli")) +
#' theme(plot.title = ggtext::element_markdown())
#' }
#' }
italicise_taxonomy <- function(string, type = c("markdown", "ansi")) {
if (missing(type)) {
type <- "markdown"

View File

@ -152,6 +152,7 @@
#' mo_is_yeast(c("Candida", "E. coli")) # TRUE, FALSE
#'
#' # gram stains and intrinsic resistance can also be used as a filter in dplyr verbs
#' \donttest{
#' if (require("dplyr")) {
#' example_isolates %>%
#' filter(mo_is_gram_positive())
@ -167,6 +168,7 @@
#' # SNOMED codes, and URL to the online database
#' mo_info("E. coli")
#' }
#' }
mo_name <- function(x, language = get_locale(), ...) {
if (missing(x)) {
# this tries to find the data and an <mo> column

View File

@ -42,7 +42,6 @@
#' # See ?example_isolates.
#'
#' \donttest{
#'
#' if (require("dplyr")) {
#' # calculate the resistance per group first
#' resistance_data <- example_isolates %>%

View File

@ -61,11 +61,13 @@
#' plot(some_mic_values, mo = "S. aureus", ab = "ampicillin")
#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
#'
#' \donttest{
#' if (require("ggplot2")) {
#' ggplot(some_mic_values)
#' ggplot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
#' ggplot(some_rsi_values)
#' }
#' }
NULL
#' @method plot mic

View File

@ -103,6 +103,7 @@
#' proportion_IR(example_isolates$AMX)
#' proportion_R(example_isolates$AMX)
#'
#' \donttest{
#' if (require("dplyr")) {
#' example_isolates %>%
#' group_by(hospital_id) %>%
@ -161,6 +162,7 @@
#' group_by(hospital_id) %>%
#' proportion_df(translate = FALSE)
#' }
#' }
resistance <- function(...,
minimum = 30,
as_percent = FALSE,

View File

@ -70,6 +70,7 @@
#' year_min = 2010,
#' model = "binomial")
#' plot(x)
#' \donttest{
#' if (require("ggplot2")) {
#' ggplot_rsi_predict(x)
#' }
@ -114,6 +115,7 @@
#' x = "Year") +
#' theme_minimal(base_size = 13)
#' }
#' }
resistance_predict <- function(x,
col_ab,
col_date = NULL,

View File

@ -101,12 +101,12 @@
#' @inheritSection AMR Read more on Our Website!
#' @examples
#' summary(example_isolates) # see all R/SI results at a glance
#'
#' \donttest{
#' if (require("skimr")) {
#' # class <rsi> supported in skim() too:
#' skim(example_isolates)
#' }
#'
#' }
#' # For INTERPRETING disk diffusion and MIC values -----------------------
#'
#' # a whole data set, even with combined MIC values and disk zones