mirror of
https://github.com/msberends/AMR.git
synced 2025-07-13 03:12:11 +02:00
as.rsi warning, site update
This commit is contained in:
11
R/rsi.R
11
R/rsi.R
@ -64,6 +64,9 @@ as.rsi <- function(x) {
|
||||
} else if (identical(levels(x), c("S", "I", "R"))) {
|
||||
structure(x, class = c('rsi', 'ordered', 'factor'))
|
||||
} else {
|
||||
if (mic_like(x) > 0.5) {
|
||||
warning("`as.rsi` is intended to clean antimicrobial interpretations - not to interpret MIC values.", call. = FALSE)
|
||||
}
|
||||
|
||||
x <- x %>% unlist()
|
||||
x.bak <- x
|
||||
@ -103,6 +106,14 @@ as.rsi <- function(x) {
|
||||
}
|
||||
}
|
||||
|
||||
mic_like <- function(x) {
|
||||
mic <- x %>%
|
||||
gsub("[^0-9.,]+", "", .) %>%
|
||||
unique()
|
||||
mic_valid <- suppressWarnings(as.mic(mic))
|
||||
sum(!is.na(mic_valid)) / length(mic)
|
||||
}
|
||||
|
||||
#' @rdname as.rsi
|
||||
#' @export
|
||||
is.rsi <- function(x) {
|
||||
|
Reference in New Issue
Block a user