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

new antibiotics

This commit is contained in:
2019-05-10 16:44:59 +02:00
parent 73f1ee1159
commit 68cc7ef0d0
147 changed files with 6228 additions and 4187 deletions

24
R/mic.R
View File

@ -25,6 +25,7 @@
#' @rdname as.mic
#' @param x vector
#' @param na.rm a logical indicating whether missing values should be removed
#' @details Interpret MIC values as RSI values with \code{\link{as.rsi}}. It supports guidelines from EUCAST and CLSI.
#' @return Ordered factor with new class \code{mic}
#' @keywords mic
#' @export
@ -38,6 +39,16 @@
#' # this can also coerce combined MIC/RSI values:
#' as.mic("<=0.002; S") # will return <=0.002
#'
#' # interpret MIC values
#' as.rsi(x = as.mic(2),
#' mo = as.mo("S. pneumoniae"),
#' ab = "AMX",
#' guideline = "EUCAST")
#' as.rsi(x = as.mic(4),
#' mo = as.mo("S. pneumoniae"),
#' ab = "AMX",
#' guideline = "EUCAST")
#'
#' plot(mic_data)
#' barplot(mic_data)
#' freq(mic_data)
@ -71,11 +82,12 @@ as.mic <- function(x, na.rm = FALSE) {
# force to be character
x <- as.character(x)
# previously unempty values now empty - should return a warning later on
## previously unempty values now empty - should return a warning later on
x[x.bak != "" & x == ""] <- "invalid"
# these are alllowed MIC values and will become factor levels
lvls <- c("<0.002", "<=0.002", "0.002", ">=0.002", ">0.002",
# these are allowed MIC values and will become factor levels
lvls <- c("<0.001", "<=0.001", "0.001", ">=0.001", ">0.001",
"<0.002", "<=0.002", "0.002", ">=0.002", ">0.002",
"<0.003", "<=0.003", "0.003", ">=0.003", ">0.003",
"<0.004", "<=0.004", "0.004", ">=0.004", ">0.004",
"<0.006", "<=0.006", "0.006", ">=0.006", ">0.006",
@ -134,11 +146,15 @@ as.mic <- function(x, na.rm = FALSE) {
"<80", "<=80", "80", ">=80", ">80",
"<96", "<=96", "96", ">=96", ">96",
"<128", "<=128", "128", ">=128", ">128",
"129",
"<160", "<=160", "160", ">=160", ">160",
"<256", "<=256", "256", ">=256", ">256",
"257",
"<320", "<=320", "320", ">=320", ">320",
"<512", "<=512", "512", ">=512", ">512",
"<1024", "<=1024", "1024", ">=1024", ">1024")
"513",
"<1024", "<=1024", "1024", ">=1024", ">1024",
"1025")
na_before <- x[is.na(x) | x == ''] %>% length()
x[!x %in% lvls] <- NA