1
0
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:
2019-02-09 22:16:24 +01:00
parent ed30312048
commit c56b179857
73 changed files with 735 additions and 421 deletions

11
R/rsi.R
View File

@ -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) {