1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 09:11:51 +02:00

add add_custom_antimicrobials()

This commit is contained in:
2022-10-10 20:20:39 +02:00
parent 4fe90092c7
commit 82e3198315
8 changed files with 209 additions and 11 deletions

View File

@ -0,0 +1,50 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add_custom_antimicrobials.R
\name{add_custom_antimicrobials}
\alias{add_custom_antimicrobials}
\alias{clear_custom_antimicrobials}
\title{Add Manual Antimicrobials to This Package}
\usage{
add_custom_antimicrobials(x)
clear_custom_antimicrobials()
}
\arguments{
\item{x}{a \link{data.frame} resembling the \link{antibiotics} data set, at least containing columns "ab" and "name"}
}
\description{
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:
\if{html}{\out{<div class="sourceCode r">}}\preformatted{library(AMR)
add_custom_antimicrobials(
data.frame(ab = "TEST",
name = "Test Antibiotic",
group = "Test Group")
)
}\if{html}{\out{</div>}}
Use \code{\link[=clear_custom_antimicrobials]{clear_custom_antimicrobials()}} to clear the previously added antimicrobials.
}
\examples{
\donttest{
# returns NA and throws a warning:
as.ab("test")
# now a manual entry - it will be considered by as.ab() and
# all ab_*() functions
add_custom_antimicrobials(
data.frame(ab = "TEST",
name = "Test Antibiotic",
group = "Test Group")
)
"test" is now a new antibiotic:
as.ab("test")
ab_name("test")
ab_group("test")
}
}

View File

@ -39,6 +39,8 @@ All these properties will be searched for the user input. The \code{\link[=as.ab
Use the \code{\link[=ab_property]{ab_*}} functions to get properties based on the returned antibiotic ID, see \emph{Examples}.
Note: the \code{\link[=as.ab]{as.ab()}} and \code{\link[=ab_property]{ab_*}} functions may use very long regular expression to match brand names of antimicrobial agents. This may fail on some systems.
You can add your own manual codes to be considered by \code{\link[=as.ab]{as.ab()}} and all \code{\link[=ab_property]{ab_*}} functions, see \code{\link[=add_custom_antimicrobials]{add_custom_antimicrobials()}}.
}
\section{Source}{