mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 01:22:25 +02:00
(v1.3.0.9008) also tibble printing for ab
This commit is contained in:
@ -575,9 +575,9 @@ isFALSE <- function(x) {
|
||||
deparse1 <- function(expr, collapse = " ", width.cutoff = 500L, ...) {
|
||||
paste(deparse(expr, width.cutoff, ...), collapse = collapse)
|
||||
}
|
||||
file.size <- function (...) {
|
||||
file.size <- function(...) {
|
||||
base::file.info(...)$size
|
||||
}
|
||||
file.mtime <- function (...) {
|
||||
file.mtime <- function(...) {
|
||||
base::file.info(...)$mtime
|
||||
}
|
||||
|
20
R/ab.R
20
R/ab.R
@ -467,6 +467,26 @@ is.ab <- function(x) {
|
||||
inherits(x, "ab")
|
||||
}
|
||||
|
||||
|
||||
#' @method pillar_shaft ab
|
||||
#' @export
|
||||
pillar_shaft.ab <- function(x, ...) {
|
||||
# import from the pillar package, without being dependent on it!
|
||||
style_na <- import_fn("style_na", "pillar", error_on_fail = FALSE)
|
||||
new_pillar_shaft_simple <- import_fn("new_pillar_shaft_simple", "pillar", error_on_fail = FALSE)
|
||||
out <- format(x)
|
||||
out[is.na(x)] <- style_na(NA)
|
||||
new_pillar_shaft_simple(out,
|
||||
align = "left",
|
||||
min_width = 4)
|
||||
}
|
||||
|
||||
#' @method type_sum ab
|
||||
#' @export
|
||||
type_sum.ab <- function(x, ...) {
|
||||
"ab"
|
||||
}
|
||||
|
||||
#' @method print ab
|
||||
#' @export
|
||||
#' @noRd
|
||||
|
@ -40,17 +40,12 @@ EUCAST_VERSION_EXPERT_RULES <- "3.1, 2016"
|
||||
#' **Note:** This function does not translate MIC values to RSI values. Use [as.rsi()] for that. \cr
|
||||
#' **Note:** When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance.
|
||||
#'
|
||||
#' Before further processing, some non-EUCAST rules can be applied to improve the efficacy of the EUCAST rules. These non-EUCAST rules, that are then applied to all isolates, are:
|
||||
#' - Inherit amoxicillin (AMX) from ampicillin (AMP), where amoxicillin (AMX) is unavailable;
|
||||
#' - Inherit ampicillin (AMP) from amoxicillin (AMX), where ampicillin (AMP) is unavailable;
|
||||
#' - Set amoxicillin (AMX) = R where amoxicillin/clavulanic acid (AMC) = R;
|
||||
#' - Set piperacillin (PIP) = R where piperacillin/tazobactam (TZP) = R;
|
||||
#' - Set trimethoprim (TMP) = R where trimethoprim/sulfamethoxazole (SXT) = R;
|
||||
#' - Set amoxicillin/clavulanic acid (AMC) = S where amoxicillin (AMX) = S;
|
||||
#' - Set piperacillin/tazobactam (TZP) = S where piperacillin (PIP) = S;
|
||||
#' - Set trimethoprim/sulfamethoxazole (SXT) = S where trimethoprim (TMP) = S.
|
||||
#' Before further processing, two non-EUCAST rules about drug combinations can be applied to improve the efficacy of the EUCAST rules. These rules are:
|
||||
#'
|
||||
#' These rules are not applied at default, since they are not approved by EUCAST. To use these rules, please use `eucast_rules(..., rules = "all")`, or set the default behaviour of the `[eucast_rules()]` function with `options(AMR.eucast_rules = "all")` (or any other valid input value(s) to the `rules` parameter).
|
||||
#' 1. A drug **with** enzyme inhibitor will be set to S if the drug **without** enzyme inhibitor is S
|
||||
#' 2. A drug **without** enzyme inhibitor will be set to R if the drug **with** enzyme inhibitor is R
|
||||
#'
|
||||
#' These rules are not applied at default, since they are not approved by EUCAST. To use these rules, use `eucast_rules(..., rules = "all")`, or set the default behaviour of the `[eucast_rules()]` function with `options(AMR.eucast_rules = "all")` (or any other valid input value(s) to the `rules` parameter).
|
||||
#'
|
||||
#' The file containing all EUCAST rules is located here: <https://github.com/msberends/AMR/blob/master/data-raw/eucast_rules.tsv>.
|
||||
#'
|
||||
|
@ -19,9 +19,11 @@
|
||||
# Visit our website for more info: https://msberends.github.io/AMR. #
|
||||
# ==================================================================== #
|
||||
|
||||
globalVariables(c("ab",
|
||||
globalVariables(c(".rowid",
|
||||
"ab",
|
||||
"ab_txt",
|
||||
"angle",
|
||||
"antibiotic",
|
||||
"antibiotics",
|
||||
"atc_group1",
|
||||
"atc_group2",
|
||||
@ -35,9 +37,11 @@ globalVariables(c("ab",
|
||||
"group",
|
||||
"hjust",
|
||||
"input",
|
||||
"intrinsic_resistant",
|
||||
"isolates",
|
||||
"lang",
|
||||
"lookup",
|
||||
"microorganism",
|
||||
"microorganisms",
|
||||
"microorganisms.codes",
|
||||
"microorganisms.old",
|
||||
|
4
R/zzz.R
4
R/zzz.R
@ -29,6 +29,8 @@
|
||||
envir = asNamespace("AMR"))
|
||||
|
||||
# support for tibble headers (type_sum) and tibble columns content (pillar_shaft)
|
||||
s3_register("pillar::pillar_shaft", "ab")
|
||||
s3_register("tibble::type_sum", "ab")
|
||||
s3_register("pillar::pillar_shaft", "mo")
|
||||
s3_register("tibble::type_sum", "mo")
|
||||
s3_register("pillar::pillar_shaft", "rsi")
|
||||
@ -87,7 +89,7 @@ create_MO.old_lookup <- function() {
|
||||
}
|
||||
|
||||
# copied from vctrs::s3_register
|
||||
s3_register <- function (generic, class, method = NULL) {
|
||||
s3_register <- function(generic, class, method = NULL) {
|
||||
stopifnot(is.character(generic), length(generic) == 1)
|
||||
stopifnot(is.character(class), length(class) == 1)
|
||||
pieces <- strsplit(generic, "::")[[1]]
|
||||
|
Reference in New Issue
Block a user