mirror of
https://github.com/msberends/AMR.git
synced 2025-07-10 23:01:58 +02:00
(v1.1.0.9009) lose dependencies
This commit is contained in:
@ -132,7 +132,7 @@ atc_online_property <- function(atc_code,
|
||||
|
||||
for (i in seq_len(length(atc_code))) {
|
||||
|
||||
progress$tick()$print()
|
||||
progress$tick()
|
||||
|
||||
atc_url <- sub("%s", atc_code[i], url, fixed = TRUE)
|
||||
|
||||
|
@ -46,12 +46,9 @@
|
||||
#'
|
||||
#' All isolates with a microbial ID of `NA` will be excluded as first isolate.
|
||||
#'
|
||||
#' The functions [filter_first_isolate()] and [filter_first_weighted_isolate()] are helper functions to quickly filter on first isolates. The function [filter_first_isolate()] is essentially equal to:
|
||||
#' The functions [filter_first_isolate()] and [filter_first_weighted_isolate()] are helper functions to quickly filter on first isolates. The function [filter_first_isolate()] is essentially equal to one of:
|
||||
#' ```
|
||||
#' x %>%
|
||||
#' mutate(only_firsts = first_isolate(x, ...)) %>%
|
||||
#' filter(only_firsts == TRUE) %>%
|
||||
#' select(-only_firsts)
|
||||
#' x %>% filter(first_isolate(., ...))
|
||||
#' ```
|
||||
#' The function [filter_first_weighted_isolate()] is essentially equal to:
|
||||
#' ```
|
||||
@ -60,7 +57,7 @@
|
||||
#' mutate(only_weighted_firsts = first_isolate(x,
|
||||
#' col_keyantibiotics = "keyab", ...)) %>%
|
||||
#' filter(only_weighted_firsts == TRUE) %>%
|
||||
#' select(-only_weighted_firsts)
|
||||
#' select(-only_weighted_firsts, -keyab)
|
||||
#' ```
|
||||
#' @section Key antibiotics:
|
||||
#' There are two ways to determine whether isolates can be included as first *weighted* isolates which will give generally the same results:
|
||||
@ -451,7 +448,7 @@ filter_first_isolate <- function(x,
|
||||
col_patient_id = NULL,
|
||||
col_mo = NULL,
|
||||
...) {
|
||||
filter(x, first_isolate(x = x,
|
||||
subset(x, first_isolate(x = x,
|
||||
col_date = col_date,
|
||||
col_patient_id = col_patient_id,
|
||||
col_mo = col_mo,
|
||||
@ -466,15 +463,23 @@ filter_first_weighted_isolate <- function(x,
|
||||
col_mo = NULL,
|
||||
col_keyantibiotics = NULL,
|
||||
...) {
|
||||
tbl_keyab <- x %>%
|
||||
mutate(keyab = suppressMessages(key_antibiotics(.,
|
||||
col_mo = col_mo,
|
||||
...))) %>%
|
||||
mutate(firsts = first_isolate(.,
|
||||
col_date = col_date,
|
||||
col_patient_id = col_patient_id,
|
||||
col_mo = col_mo,
|
||||
col_keyantibiotics = "keyab",
|
||||
...))
|
||||
x[which(tbl_keyab$firsts == TRUE), ]
|
||||
y <- x
|
||||
if (is.null(col_keyantibiotics)) {
|
||||
# first try to look for it
|
||||
col_keyantibiotics <- search_type_in_df(x = x, type = "keyantibiotics")
|
||||
# still NULL? Then create it since we are calling filter_first_WEIGHTED_isolate()
|
||||
if (is.null(col_keyantibiotics)) {
|
||||
y$keyab <- suppressMessages(key_antibiotics(x,
|
||||
col_mo = col_mo,
|
||||
...))
|
||||
col_keyantibiotics <- "keyab"
|
||||
}
|
||||
}
|
||||
|
||||
subset(x, first_isolate(x = y,
|
||||
col_date = col_date,
|
||||
col_patient_id = col_patient_id,
|
||||
col_mo = col_mo,
|
||||
col_keyantibiotics = col_keyantibiotics,
|
||||
...))
|
||||
}
|
||||
|
@ -214,11 +214,9 @@ key_antibiotics <- function(x,
|
||||
warning("only using ", length(gram_negative), " different antibiotics as key antibiotics for Gram-negatives. See ?key_antibiotics.", call. = FALSE)
|
||||
}
|
||||
|
||||
# join to microorganisms data set
|
||||
x <- x %>% as.data.frame(stringsAsFactors = FALSE)
|
||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||
x[, col_mo] <- as.mo(x[, col_mo, drop = TRUE])
|
||||
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL)
|
||||
|
||||
x$key_ab <- NA_character_
|
||||
|
||||
# Gram +
|
||||
|
Reference in New Issue
Block a user