mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 06:02:01 +02:00
added prevalence column and alterted as.mo algorith to use it, added ab_name as alias
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
#' Use these functions to return a specific property of an antibiotic from the \code{\link{antibiotics}} data set, based on their ATC code. Get such a code with \code{\link{as.atc}}.
|
||||
#' @param x a (vector of a) valid \code{\link{atc}} code or any text that can be coerced to a valid atc with \code{\link{as.atc}}
|
||||
#' @param property one of the column names of one of the \code{\link{antibiotics}} data set, like \code{"atc"} and \code{"official"}
|
||||
#' @param language language of the returned text, defaults to the systems language. Either one of \code{"en"} (English) or \code{"nl"} (Dutch).
|
||||
#' @rdname ab_property
|
||||
#' @return A vector of values. In case of \code{ab_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names.
|
||||
#' @export
|
||||
@ -28,8 +29,8 @@
|
||||
#' @seealso \code{\link{antibiotics}}
|
||||
#' @examples
|
||||
#' ab_atc("amcl") # J01CR02
|
||||
#' ab_official("amcl") # Amoxicillin and beta-lactamase inhibitor
|
||||
#' ab_official_nl("amcl") # Amoxicilline met enzymremmer
|
||||
#' ab_name("amcl") # Amoxicillin and beta-lactamase inhibitor
|
||||
#' ab_name("amcl", "nl") # Amoxicilline met enzymremmer
|
||||
#' ab_trivial_nl("amcl") # Amoxicilline/clavulaanzuur
|
||||
#' ab_certe("amcl") # amcl
|
||||
#' ab_umcg("amcl") # AMCL
|
||||
@ -56,15 +57,25 @@ ab_atc <- function(x) {
|
||||
|
||||
#' @rdname ab_property
|
||||
#' @export
|
||||
ab_official <- function(x) {
|
||||
ab_property(x, "official")
|
||||
ab_official <- function(x, language = NULL) {
|
||||
|
||||
if (is.null(language)) {
|
||||
language <- Sys.locale()
|
||||
} else {
|
||||
language <- tolower(language[1])
|
||||
}
|
||||
if (language %in% c("en", "")) {
|
||||
ab_property(x, "official")
|
||||
} else if (language == "nl") {
|
||||
ab_property(x, "official_nl")
|
||||
} else {
|
||||
stop("Unsupported language: '", language, "' - use one of: 'en', 'nl'", call. = FALSE)
|
||||
}
|
||||
}
|
||||
|
||||
#' @rdname ab_property
|
||||
#' @export
|
||||
ab_official_nl <- function(x) {
|
||||
ab_property(x, "official_nl")
|
||||
}
|
||||
ab_name <- ab_official
|
||||
|
||||
#' @rdname ab_property
|
||||
#' @export
|
||||
|
Reference in New Issue
Block a user