diff --git a/DESCRIPTION b/DESCRIPTION index 5dbbc199..0e542fcf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.8.2.9011 +Version: 1.8.2.9012 Date: 2022-10-10 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 895095fd..71a1d94c 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.2.9011 +# AMR 1.8.2.9012 This version will eventually become v2.0! We're happy to reach a new major milestone soon! diff --git a/R/ab_property.R b/R/ab_property.R index f00db75a..983ee35f 100644 --- a/R/ab_property.R +++ b/R/ab_property.R @@ -458,7 +458,7 @@ ab_validate <- function(x, property, ...) { } else { # try to catch an error when inputting an invalid argument # so the 'call.' can be set to FALSE - tryCatch(x[1L] %in% AMR::antibiotics[1, property, drop = TRUE], + tryCatch(x[1L] %in% AB_lookup[1, property, drop = TRUE], error = function(e) stop(e$message, call. = FALSE) ) diff --git a/R/add_custom_antimicrobials.R b/R/add_custom_antimicrobials.R index 1548ef7e..9c320f93 100644 --- a/R/add_custom_antimicrobials.R +++ b/R/add_custom_antimicrobials.R @@ -31,9 +31,13 @@ #' #' With [add_custom_antimicrobials()] you can add your own manual antimicrobial codes to the `AMR` package. #' @param x a [data.frame] resembling the [antibiotics] data set, at least containing columns "ab" and "name" -#' @details Due to how \R works, the [add_custom_antimicrobials()] function has to be run in every \R session - added antimicrobials are not stored between sessions and are thus lost when \R is exited. It is possible to save the antimicrobial additions to your `.Rprofile` file to circumvent this, for example: +#' @details Due to how \R works, the [add_custom_antimicrobials()] function has to be run in every \R session - added antimicrobials are not stored between sessions and are thus lost when \R is exited. It is possible to save the antimicrobial additions to your `.Rprofile` file to circumvent this, although this requires to load the `AMR` package at every start-up: #' #' ```r +#' # Open .Rprofile file +#' utils::file.edit("~/.Rprofile") +#' +#' # Add custom antibiotic codes: #' library(AMR) #' add_custom_antimicrobials( #' data.frame(ab = "TEST", @@ -46,12 +50,12 @@ #' @rdname add_custom_antimicrobials #' @export #' @examples -#' \donttest{ +#' # returns NA and throws a warning (which is now suppressed): +#' suppressWarnings( +#' as.ab("test") +#' ) #' -#' # returns NA and throws a warning: -#' as.ab("test") -#' -#' # now a manual entry - it will be considered by as.ab() and +#' # now add a manual entry - it will be considered by as.ab() and #' # all ab_*() functions #' add_custom_antimicrobials( #' data.frame(ab = "TEST", @@ -63,7 +67,8 @@ #' as.ab("test") #' ab_name("test") #' ab_group("test") -#' } +#' +#' ab_info("test") add_custom_antimicrobials <- function(x) { meet_criteria(x, allow_class = "data.frame") stop_ifnot(all(c("ab", "name") %in% colnames(x)), diff --git a/man/add_custom_antimicrobials.Rd b/man/add_custom_antimicrobials.Rd index de69e6d6..36b1f450 100644 --- a/man/add_custom_antimicrobials.Rd +++ b/man/add_custom_antimicrobials.Rd @@ -16,9 +16,13 @@ clear_custom_antimicrobials() With \code{\link[=add_custom_antimicrobials]{add_custom_antimicrobials()}} you can add your own manual antimicrobial codes to the \code{AMR} package. } \details{ -Due to how \R works, the \code{\link[=add_custom_antimicrobials]{add_custom_antimicrobials()}} function has to be run in every \R session - added antimicrobials are not stored between sessions and are thus lost when \R is exited. It is possible to save the antimicrobial additions to your \code{.Rprofile} file to circumvent this, for example: +Due to how \R works, the \code{\link[=add_custom_antimicrobials]{add_custom_antimicrobials()}} function has to be run in every \R session - added antimicrobials are not stored between sessions and are thus lost when \R is exited. It is possible to save the antimicrobial additions to your \code{.Rprofile} file to circumvent this, although this requires to load the \code{AMR} package at every start-up: -\if{html}{\out{
}}\preformatted{library(AMR) +\if{html}{\out{
}}\preformatted{# Open .Rprofile file +utils::file.edit("~/.Rprofile") + +# Add custom antibiotic codes: +library(AMR) add_custom_antimicrobials( data.frame(ab = "TEST", name = "Test Antibiotic", @@ -29,12 +33,12 @@ add_custom_antimicrobials( Use \code{\link[=clear_custom_antimicrobials]{clear_custom_antimicrobials()}} to clear the previously added antimicrobials. } \examples{ -\donttest{ +# returns NA and throws a warning (which is now suppressed): +suppressWarnings( + as.ab("test") +) -# returns NA and throws a warning: -as.ab("test") - -# now a manual entry - it will be considered by as.ab() and +# now add a manual entry - it will be considered by as.ab() and # all ab_*() functions add_custom_antimicrobials( data.frame(ab = "TEST", @@ -46,5 +50,6 @@ add_custom_antimicrobials( as.ab("test") ab_name("test") ab_group("test") -} + +ab_info("test") }