mirror of
https://github.com/msberends/AMR.git
synced 2025-07-10 21:41:54 +02:00
(v2.1.1.9155) new mic_p50()
and mic_p90()
- updated AMR intro
This commit is contained in:
@ -1390,6 +1390,9 @@ as_original_data_class <- function(df, old_class = NULL, extra_class = NULL) {
|
||||
fn <- function(x) base::as.data.frame(df, stringsAsFactors = FALSE)
|
||||
}
|
||||
out <- fn(df)
|
||||
# don't keep row names
|
||||
rownames(out) <- NULL
|
||||
# add additional class if needed
|
||||
if (!is.null(extra_class)) {
|
||||
class(out) <- c(extra_class, class(out))
|
||||
}
|
||||
|
@ -923,19 +923,16 @@ antibiogram.default <- function(x,
|
||||
}
|
||||
}
|
||||
|
||||
out <- as_original_data_class(new_df, class(x), extra_class = "antibiogram")
|
||||
out <- structure(as_original_data_class(new_df, class(x), extra_class = "antibiogram"),
|
||||
has_syndromic_group = has_syndromic_group,
|
||||
combine_SI = combine_SI,
|
||||
wisca = wisca,
|
||||
conf_interval = conf_interval,
|
||||
formatting_type = formatting_type,
|
||||
wisca_parameters = as_original_data_class(wisca_parameters, class(x)),
|
||||
long_numeric = as_original_data_class(long_numeric, class(x)))
|
||||
rownames(out) <- NULL
|
||||
rownames(wisca_parameters) <- NULL
|
||||
rownames(long_numeric) <- NULL
|
||||
structure(out,
|
||||
has_syndromic_group = has_syndromic_group,
|
||||
combine_SI = combine_SI,
|
||||
wisca = wisca,
|
||||
conf_interval = conf_interval,
|
||||
formatting_type = formatting_type,
|
||||
wisca_parameters = as_original_data_class(wisca_parameters, class(x)),
|
||||
long_numeric = as_original_data_class(long_numeric, class(x))
|
||||
)
|
||||
out
|
||||
}
|
||||
|
||||
#' @method antibiogram grouped_df
|
||||
@ -1041,14 +1038,16 @@ antibiogram.grouped_df <- function(x,
|
||||
|
||||
close(progress)
|
||||
|
||||
structure(as_original_data_class(out, class(x), extra_class = "antibiogram"),
|
||||
has_syndromic_group = FALSE,
|
||||
combine_SI = isTRUE(combine_SI),
|
||||
wisca = isTRUE(wisca),
|
||||
conf_interval = conf_interval,
|
||||
formatting_type = formatting_type,
|
||||
wisca_parameters = as_original_data_class(wisca_parameters, class(x)),
|
||||
long_numeric = as_original_data_class(long_numeric, class(x)))
|
||||
out <- structure(as_original_data_class(out, class(x), extra_class = "antibiogram"),
|
||||
has_syndromic_group = FALSE,
|
||||
combine_SI = isTRUE(combine_SI),
|
||||
wisca = isTRUE(wisca),
|
||||
conf_interval = conf_interval,
|
||||
formatting_type = formatting_type,
|
||||
wisca_parameters = as_original_data_class(wisca_parameters, class(x)),
|
||||
long_numeric = as_original_data_class(long_numeric, class(x)))
|
||||
rownames(out) <- NULL
|
||||
out
|
||||
}
|
||||
|
||||
#' @export
|
||||
|
@ -185,8 +185,9 @@ bug_drug_combinations <- function(x,
|
||||
|
||||
out <- as_original_data_class(out, class(x.bak)) # will remove tibble groups
|
||||
out <- out %pm>% pm_arrange(mo, ab)
|
||||
class(out) <- c("bug_drug_combinations", if(data_has_groups) "grouped" else NULL, class(out))
|
||||
rownames(out) <- NULL
|
||||
structure(out, class = c("bug_drug_combinations", if(data_has_groups) "grouped" else NULL, class(out)))
|
||||
out
|
||||
}
|
||||
|
||||
#' @method format bug_drug_combinations
|
||||
|
15
R/mic.R
15
R/mic.R
@ -346,6 +346,21 @@ rescale_mic <- function(x, mic_range, keep_operators = "edges", as.mic = TRUE) {
|
||||
out
|
||||
}
|
||||
|
||||
#' @rdname as.mic
|
||||
#' @details Use [mic_p50()] and [mic_p90()] to get the 50th and 90th percentile of MIC values. They return 'normal' [numeric] values.
|
||||
#' @export
|
||||
mic_p50 <- function(x, na.rm = FALSE, ...) {
|
||||
x <- as.mic(x)
|
||||
as.double(stats::quantile(x, probs = 0.5, na.rm = na.rm))
|
||||
}
|
||||
|
||||
#' @rdname as.mic
|
||||
#' @export
|
||||
mic_p90 <- function(x, na.rm = FALSE, ...) {
|
||||
x <- as.mic(x)
|
||||
as.double(stats::quantile(x, probs = 0.9, na.rm = na.rm))
|
||||
}
|
||||
|
||||
#' @method as.double mic
|
||||
#' @export
|
||||
#' @noRd
|
||||
|
@ -186,7 +186,7 @@
|
||||
#' scale_colour_sir(language = "pt",
|
||||
#' name = "Support in 20 languages")
|
||||
#' }
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#' # Plotting using base R's plot() ---------------------------------------
|
||||
#'
|
||||
|
2
R/sir.R
2
R/sir.R
@ -1544,7 +1544,7 @@ sir_interpretation_history <- function(clean = FALSE) {
|
||||
if (pkg_is_available("tibble")) {
|
||||
out <- import_fn("as_tibble", "tibble")(out)
|
||||
}
|
||||
structure(out, class = c("sir_log", class(out)))
|
||||
as_original_data_class(out, class(out), extra_class = "sir_log")
|
||||
}
|
||||
|
||||
#' @method print sir_log
|
||||
|
@ -383,8 +383,6 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
|
||||
# remove redundant columns
|
||||
out <- subset(out, select = -c(ci_min, ci_max, isolates))
|
||||
}
|
||||
|
||||
rownames(out) <- NULL
|
||||
out <- as_original_data_class(out, class(data.bak)) # will remove tibble groups
|
||||
structure(out, class = c("sir_df", class(out)))
|
||||
|
||||
as_original_data_class(out, class(data.bak), extra_class = "sir_df") # will remove tibble groups
|
||||
}
|
||||
|
Reference in New Issue
Block a user