mirror of
https://github.com/msberends/AMR.git
synced 2025-01-16 00:41:53 +01:00
Compare commits
2 Commits
3deeedc4b6
...
57d66cd9d0
Author | SHA1 | Date | |
---|---|---|---|
57d66cd9d0 | |||
955f9d7020 |
@ -1,5 +1,5 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.8.2.9011
|
Version: 1.8.2.9013
|
||||||
Date: 2022-10-10
|
Date: 2022-10-10
|
||||||
Title: Antimicrobial Resistance Data Analysis
|
Title: Antimicrobial Resistance Data Analysis
|
||||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
|||||||
# AMR 1.8.2.9011
|
# AMR 1.8.2.9013
|
||||||
|
|
||||||
This version will eventually become v2.0! We're happy to reach a new major milestone soon!
|
This version will eventually become v2.0! We're happy to reach a new major milestone soon!
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ ab_validate <- function(x, property, ...) {
|
|||||||
} else {
|
} else {
|
||||||
# try to catch an error when inputting an invalid argument
|
# try to catch an error when inputting an invalid argument
|
||||||
# so the 'call.' can be set to FALSE
|
# 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)
|
error = function(e) stop(e$message, call. = FALSE)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,13 +27,17 @@
|
|||||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
#' Add Manual Antimicrobials to This Package
|
#' Add Custom Antimicrobials to This Package
|
||||||
#'
|
#'
|
||||||
#' With [add_custom_antimicrobials()] you can add your own manual antimicrobial codes to the `AMR` package.
|
#' With [add_custom_antimicrobials()] you can add your own custom antimicrobial codes to the `AMR` package.
|
||||||
#' @param x a [data.frame] resembling the [antibiotics] data set, at least containing columns "ab" and "name"
|
#' @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
|
#' ```r
|
||||||
|
#' # Open .Rprofile file
|
||||||
|
#' utils::file.edit("~/.Rprofile")
|
||||||
|
#'
|
||||||
|
#' # Add custom antibiotic codes:
|
||||||
#' library(AMR)
|
#' library(AMR)
|
||||||
#' add_custom_antimicrobials(
|
#' add_custom_antimicrobials(
|
||||||
#' data.frame(ab = "TEST",
|
#' data.frame(ab = "TEST",
|
||||||
@ -46,24 +50,27 @@
|
|||||||
#' @rdname add_custom_antimicrobials
|
#' @rdname add_custom_antimicrobials
|
||||||
#' @export
|
#' @export
|
||||||
#' @examples
|
#' @examples
|
||||||
#' \donttest{
|
#' # returns NA and throws a warning (which is now suppressed):
|
||||||
#'
|
#' suppressWarnings(
|
||||||
#' # returns NA and throws a warning:
|
|
||||||
#' as.ab("test")
|
#' as.ab("test")
|
||||||
|
#' )
|
||||||
#'
|
#'
|
||||||
#' # now a manual entry - it will be considered by as.ab() and
|
#' # now add a custom entry - it will be considered by as.ab() and
|
||||||
#' # all ab_*() functions
|
#' # all ab_*() functions
|
||||||
#' add_custom_antimicrobials(
|
#' add_custom_antimicrobials(
|
||||||
#' data.frame(ab = "TEST",
|
#' data.frame(ab = "TEST",
|
||||||
#' name = "Test Antibiotic",
|
#' name = "Test Antibiotic",
|
||||||
|
#' # you can add any property present in the
|
||||||
|
#' # 'antibiotics' data set, such as 'group':
|
||||||
#' group = "Test Group")
|
#' group = "Test Group")
|
||||||
#' )
|
#' )
|
||||||
#'
|
#'
|
||||||
#' "test" is now a new antibiotic:
|
#' # "test" is now a new antibiotic:
|
||||||
#' as.ab("test")
|
#' as.ab("test")
|
||||||
#' ab_name("test")
|
#' ab_name("test")
|
||||||
#' ab_group("test")
|
#' ab_group("test")
|
||||||
#' }
|
#'
|
||||||
|
#' ab_info("test")
|
||||||
add_custom_antimicrobials <- function(x) {
|
add_custom_antimicrobials <- function(x) {
|
||||||
meet_criteria(x, allow_class = "data.frame")
|
meet_criteria(x, allow_class = "data.frame")
|
||||||
stop_ifnot(all(c("ab", "name") %in% colnames(x)),
|
stop_ifnot(all(c("ab", "name") %in% colnames(x)),
|
||||||
@ -94,5 +101,5 @@ clear_custom_antimicrobials <- function() {
|
|||||||
assignInNamespace(x = "AB_lookup",
|
assignInNamespace(x = "AB_lookup",
|
||||||
value = create_AB_lookup(),
|
value = create_AB_lookup(),
|
||||||
ns = asNamespace("AMR"))
|
ns = asNamespace("AMR"))
|
||||||
message_("Manual antimicrobials cleared.")
|
message_("Custom antimicrobials cleared.")
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
\name{add_custom_antimicrobials}
|
\name{add_custom_antimicrobials}
|
||||||
\alias{add_custom_antimicrobials}
|
\alias{add_custom_antimicrobials}
|
||||||
\alias{clear_custom_antimicrobials}
|
\alias{clear_custom_antimicrobials}
|
||||||
\title{Add Manual Antimicrobials to This Package}
|
\title{Add Custom Antimicrobials to This Package}
|
||||||
\usage{
|
\usage{
|
||||||
add_custom_antimicrobials(x)
|
add_custom_antimicrobials(x)
|
||||||
|
|
||||||
@ -13,12 +13,16 @@ clear_custom_antimicrobials()
|
|||||||
\item{x}{a \link{data.frame} resembling the \link{antibiotics} data set, at least containing columns "ab" and "name"}
|
\item{x}{a \link{data.frame} resembling the \link{antibiotics} data set, at least containing columns "ab" and "name"}
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
With \code{\link[=add_custom_antimicrobials]{add_custom_antimicrobials()}} you can add your own manual antimicrobial codes to the \code{AMR} package.
|
With \code{\link[=add_custom_antimicrobials]{add_custom_antimicrobials()}} you can add your own custom antimicrobial codes to the \code{AMR} package.
|
||||||
}
|
}
|
||||||
\details{
|
\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{<div class="sourceCode r">}}\preformatted{library(AMR)
|
\if{html}{\out{<div class="sourceCode r">}}\preformatted{# Open .Rprofile file
|
||||||
|
utils::file.edit("~/.Rprofile")
|
||||||
|
|
||||||
|
# Add custom antibiotic codes:
|
||||||
|
library(AMR)
|
||||||
add_custom_antimicrobials(
|
add_custom_antimicrobials(
|
||||||
data.frame(ab = "TEST",
|
data.frame(ab = "TEST",
|
||||||
name = "Test Antibiotic",
|
name = "Test Antibiotic",
|
||||||
@ -29,22 +33,25 @@ add_custom_antimicrobials(
|
|||||||
Use \code{\link[=clear_custom_antimicrobials]{clear_custom_antimicrobials()}} to clear the previously added antimicrobials.
|
Use \code{\link[=clear_custom_antimicrobials]{clear_custom_antimicrobials()}} to clear the previously added antimicrobials.
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
\donttest{
|
# returns NA and throws a warning (which is now suppressed):
|
||||||
|
suppressWarnings(
|
||||||
# returns NA and throws a warning:
|
|
||||||
as.ab("test")
|
as.ab("test")
|
||||||
|
)
|
||||||
|
|
||||||
# now a manual entry - it will be considered by as.ab() and
|
# now add a custom entry - it will be considered by as.ab() and
|
||||||
# all ab_*() functions
|
# all ab_*() functions
|
||||||
add_custom_antimicrobials(
|
add_custom_antimicrobials(
|
||||||
data.frame(ab = "TEST",
|
data.frame(ab = "TEST",
|
||||||
name = "Test Antibiotic",
|
name = "Test Antibiotic",
|
||||||
|
# you can add any property present in the
|
||||||
|
# 'antibiotics' data set, such as 'group':
|
||||||
group = "Test Group")
|
group = "Test Group")
|
||||||
)
|
)
|
||||||
|
|
||||||
"test" is now a new antibiotic:
|
# "test" is now a new antibiotic:
|
||||||
as.ab("test")
|
as.ab("test")
|
||||||
ab_name("test")
|
ab_name("test")
|
||||||
ab_group("test")
|
ab_group("test")
|
||||||
}
|
|
||||||
|
ab_info("test")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user