N for only 1 AB in

This commit is contained in:
dr. M.S. (Matthijs) Berends 2023-02-22 16:26:13 +01:00
parent 551aaf6517
commit a84101db08
4 changed files with 35 additions and 30 deletions

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 1.8.2.9140 Version: 1.8.2.9141
Date: 2023-02-22 Date: 2023-02-22
Title: Antimicrobial Resistance Data Analysis Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR) Description: Functions to simplify and standardise antimicrobial resistance (AMR)

View File

@ -1,4 +1,4 @@
# AMR 1.8.2.9140 # AMR 1.8.2.9141
*(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)* *(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)*

View File

@ -191,8 +191,7 @@
#' antibiotics = aminoglycosides(), #' antibiotics = aminoglycosides(),
#' ab_transform = "name", #' ab_transform = "name",
#' syndromic_group = ifelse(ex1$ward == "ICU", #' syndromic_group = ifelse(ex1$ward == "ICU",
#' "UCI", "No UCI" #' "UCI", "No UCI"),
#' ),
#' language = "es" #' language = "es"
#' ) #' )
#' #'
@ -488,9 +487,16 @@ antibiogram <- function(x,
count_group <- n_per_mo$count[match(new_df[[1]], n_per_mo$mo)] count_group <- n_per_mo$count[match(new_df[[1]], n_per_mo$mo)]
edit_col <- 1 edit_col <- 1
} }
if (NCOL(new_df) == edit_col + 1) {
# only 1 antibiotic
new_df[[edit_col]] <- paste0(new_df[[edit_col]], " (", unlist(lapply(strsplit(count_group, "-"), function(x) x[1])), ")")
colnames(new_df)[edit_col] <- paste(colnames(new_df)[edit_col], "(N)")
} else {
# more than 1 antibiotic
new_df[[edit_col]] <- paste0(new_df[[edit_col]], " (", count_group, ")") new_df[[edit_col]] <- paste0(new_df[[edit_col]], " (", count_group, ")")
colnames(new_df)[edit_col] <- paste(colnames(new_df)[edit_col], "(N min-max)") colnames(new_df)[edit_col] <- paste(colnames(new_df)[edit_col], "(N min-max)")
} }
}
out <- as_original_data_class(new_df, class(x), extra_class = "antibiogram") out <- as_original_data_class(new_df, class(x), extra_class = "antibiogram")
rownames(out) <- NULL rownames(out) <- NULL

View File

@ -220,8 +220,7 @@ antibiogram(ex1,
antibiotics = aminoglycosides(), antibiotics = aminoglycosides(),
ab_transform = "name", ab_transform = "name",
syndromic_group = ifelse(ex1$ward == "ICU", syndromic_group = ifelse(ex1$ward == "ICU",
"UCI", "No UCI" "UCI", "No UCI"),
),
language = "es" language = "es"
) )