2018-02-21 11:52:31 +01:00
# ==================================================================== #
# TITLE #
# Antimicrobial Resistance (AMR) Analysis #
# #
2019-01-02 23:24:07 +01:00
# SOURCE #
# https://gitlab.com/msberends/AMR #
2018-02-21 11:52:31 +01:00
# #
# LICENCE #
2019-01-02 23:24:07 +01:00
# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) #
2018-02-21 11:52:31 +01:00
# #
2019-01-02 23:24:07 +01:00
# This R package is free software; you can freely use and distribute #
# it for both personal and commercial purposes under the terms of the #
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
# the Free Software Foundation. #
# #
# This R package was created for academic research and was publicly #
# released in the hope that it will be useful, but it comes WITHOUT #
# ANY WARRANTY OR LIABILITY. #
2019-04-05 18:47:39 +02:00
# Visit our website for more info: https://msberends.gitlab.io/AMR. #
2018-02-21 11:52:31 +01:00
# ==================================================================== #
2018-09-04 11:33:30 +02:00
#' Transform to ATC code
2018-08-25 22:01:14 +02:00
#'
2018-09-04 11:33:30 +02:00
#' Use this function to determine the ATC code of one or more antibiotics. The data set \code{\link{antibiotics}} will be searched for abbreviations, official names and trade names.
2018-08-25 22:01:14 +02:00
#' @param x character vector to determine \code{ATC} code
#' @rdname as.atc
#' @aliases atc
#' @keywords atc
2019-01-25 13:18:41 +01:00
#' @inheritSection WHOCC WHOCC
2018-08-25 22:01:14 +02:00
#' @export
#' @importFrom dplyr %>% filter slice pull
2018-08-28 13:51:13 +02:00
#' @details Use the \code{\link{ab_property}} functions to get properties based on the returned ATC code, see Examples.
#'
#' In the ATC classification system, the active substances are classified in a hierarchy with five different levels. The system has fourteen main anatomical/pharmacological groups or 1st levels. Each ATC main group is divided into 2nd levels which could be either pharmacological or therapeutic groups. The 3rd and 4th levels are chemical, pharmacological or therapeutic subgroups and the 5th level is the chemical substance. The 2nd, 3rd and 4th levels are often used to identify pharmacological subgroups when that is considered more appropriate than therapeutic or chemical subgroups.
2018-08-25 22:01:14 +02:00
#' Source: \url{https://www.whocc.no/atc/structure_and_principles/}
2019-05-16 21:20:00 +02:00
#' @return Character (vector) with class \code{"atc"}. Unknown values will return \code{NA}.
2018-09-01 21:19:46 +02:00
#' @seealso \code{\link{antibiotics}} for the dataframe that is being used to determine ATCs.
2019-01-02 23:24:07 +01:00
#' @inheritSection AMR Read more on our website!
2018-08-25 22:01:14 +02:00
#' @examples
#' # These examples all return "J01FA01", the ATC code of Erythromycin:
#' as.atc("J01FA01")
#' as.atc("Erythromycin")
#' as.atc("eryt")
2018-10-22 12:32:59 +02:00
#' as.atc(" eryt 123")
2018-08-25 22:01:14 +02:00
#' as.atc("ERYT")
#' as.atc("ERY")
as.atc <- function ( x ) {
2019-05-10 16:44:59 +02:00
ab_atc ( x )
2018-08-25 22:01:14 +02:00
}
#' @rdname as.atc
#' @export
is.atc <- function ( x ) {
identical ( class ( x ) , " atc" )
}
#' @exportMethod print.atc
#' @export
#' @noRd
print.atc <- function ( x , ... ) {
cat ( " Class 'atc'\n" )
print.default ( as.character ( x ) , quote = FALSE )
}
#' @exportMethod as.data.frame.atc
#' @export
#' @noRd
as.data.frame.atc <- function ( x , ... ) {
# same as as.data.frame.character but with removed stringsAsFactors
nm <- paste ( deparse ( substitute ( x ) , width.cutoff = 500L ) ,
collapse = " " )
if ( ! " nm" %in% names ( list ( ... ) ) ) {
as.data.frame.vector ( x , ... , nm = nm )
} else {
as.data.frame.vector ( x , ... )
}
}
#' @exportMethod pull.atc
#' @export
#' @importFrom dplyr pull
#' @noRd
pull.atc <- function ( .data , ... ) {
pull ( as.data.frame ( .data ) , ... )
}