1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-26 17:26:12 +01:00
AMR/man/add_custom_antimicrobials.Rd

80 lines
2.5 KiB
Plaintext
Raw Normal View History

2022-10-10 20:20:39 +02:00
% 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}
2022-10-10 21:38:39 +02:00
\title{Add Custom Antimicrobials to This Package}
2022-10-10 20:20:39 +02:00
\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{
2022-10-10 21:38:39 +02:00
With \code{\link[=add_custom_antimicrobials]{add_custom_antimicrobials()}} you can add your own custom antimicrobial codes to the \code{AMR} package.
2022-10-10 20:20:39 +02:00
}
\details{
2022-10-10 21:03:39 +02:00
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:
2022-10-10 20:20:39 +02:00
2022-10-10 21:03:39 +02:00
\if{html}{\out{<div class="sourceCode r">}}\preformatted{# Open .Rprofile file
utils::file.edit("~/.Rprofile")
# Add custom antibiotic codes:
library(AMR)
2022-10-10 20:20:39 +02:00
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{
2022-10-15 15:20:13 +02:00
\donttest{
2022-10-10 21:03:39 +02:00
# returns NA and throws a warning (which is now suppressed):
suppressWarnings(
as.ab("test")
)
2022-10-10 20:20:39 +02:00
2022-10-10 21:38:39 +02:00
# now add a custom entry - it will be considered by as.ab() and
2022-10-10 20:20:39 +02:00
# all ab_*() functions
add_custom_antimicrobials(
data.frame(ab = "TEST",
name = "Test Antibiotic",
2022-10-10 21:38:39 +02:00
# you can add any property present in the
# 'antibiotics' data set, such as 'group':
2022-10-10 20:20:39 +02:00
group = "Test Group")
)
2022-10-10 21:38:39 +02:00
# "test" is now a new antibiotic:
2022-10-10 20:20:39 +02:00
as.ab("test")
ab_name("test")
ab_group("test")
2022-10-10 21:03:39 +02:00
ab_info("test")
# Add Co-fluampicil, which is one of the many J01CR50 codes, see
# https://www.whocc.no/ddd/list_of_ddds_combined_products/
add_custom_antimicrobials(
data.frame(ab = "COFLU",
name = "Co-fluampicil",
atc = "J01CR50",
group = "Beta-lactams/penicillines")
)
ab_atc("Co-fluampicil")
ab_name("J01CR50")
# even antibiotic selectors work
x <- data.frame(random_column = "test",
2022-10-14 13:02:50 +02:00
coflu = as.rsi("S"),
ampicillin = as.rsi("R"))
x
x[, betalactams()]
2022-10-10 20:20:39 +02:00
}
2022-10-15 15:20:13 +02:00
}