mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 16:42:10 +02:00
(v1.2.0.9007) Tidyverse selections
This commit is contained in:
75
man/antibiotic_class_selectors.Rd
Normal file
75
man/antibiotic_class_selectors.Rd
Normal file
@ -0,0 +1,75 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/ab_class_selectors.R
|
||||
\name{antibiotic_class_selectors}
|
||||
\alias{antibiotic_class_selectors}
|
||||
\alias{aminoglycosides}
|
||||
\alias{carbapenems}
|
||||
\alias{cephalosporins}
|
||||
\alias{cephalosporins_1st}
|
||||
\alias{cephalosporins_2nd}
|
||||
\alias{cephalosporins_3rd}
|
||||
\alias{cephalosporins_4th}
|
||||
\alias{cephalosporins_5th}
|
||||
\alias{fluoroquinolones}
|
||||
\alias{glycopeptides}
|
||||
\alias{macrolides}
|
||||
\alias{penicillins}
|
||||
\alias{tetracyclines}
|
||||
\title{Antibiotic class selectors}
|
||||
\usage{
|
||||
aminoglycosides()
|
||||
|
||||
carbapenems()
|
||||
|
||||
cephalosporins()
|
||||
|
||||
cephalosporins_1st()
|
||||
|
||||
cephalosporins_2nd()
|
||||
|
||||
cephalosporins_3rd()
|
||||
|
||||
cephalosporins_4th()
|
||||
|
||||
cephalosporins_5th()
|
||||
|
||||
fluoroquinolones()
|
||||
|
||||
glycopeptides()
|
||||
|
||||
macrolides()
|
||||
|
||||
penicillins()
|
||||
|
||||
tetracyclines()
|
||||
}
|
||||
\description{
|
||||
Use these selection helpers inside any function that allows \href{https://tidyselect.r-lib.org/reference/language.html}{Tidyverse selections}, like \code{dplyr::select()} or \code{tidyr::pivot_longer()}. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
|
||||
}
|
||||
\details{
|
||||
All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a selector like e.g. \code{\link[=aminoglycosides]{aminoglycosides()}} will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
|
||||
|
||||
These functions only work if the \code{tidyselect} package is installed, that comes with the \code{dplyr} package. An error will be thrown if \code{tidyselect} package is not installed, or if the functions are used outside a function that allows Tidyverse selections like \code{select()} or \code{pivot_longer()}.
|
||||
}
|
||||
\examples{
|
||||
if (require("dplyr")) {
|
||||
|
||||
# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
||||
example_isolates \%>\%
|
||||
select(carbapenems())
|
||||
|
||||
|
||||
# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
|
||||
example_isolates \%>\%
|
||||
select(mo, aminoglycosides())
|
||||
|
||||
|
||||
data.frame(irrelevant = "value",
|
||||
J01CA01 = "S") \%>\% # ATC code of ampicillin
|
||||
select(penicillins()) # so the 'J01CA01' column is selected
|
||||
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=filter_ab_class]{filter_ab_class()}} for the \code{filter()} equivalent.
|
||||
}
|
@ -48,7 +48,7 @@ filter_tetracyclines(x, result = NULL, scope = "any", ...)
|
||||
\arguments{
|
||||
\item{x}{a data set}
|
||||
|
||||
\item{ab_class}{an antimicrobial class, like \code{"carbapenems"}, as can be found in \code{\link[=antibiotics]{antibiotics$group}}}
|
||||
\item{ab_class}{an antimicrobial class, like \code{"carbapenems"}. The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched (case-insensitive) for this value.}
|
||||
|
||||
\item{result}{an antibiotic result: S, I or R (or a combination of more of them)}
|
||||
|
||||
@ -60,7 +60,7 @@ filter_tetracyclines(x, result = NULL, scope = "any", ...)
|
||||
Filter isolates on results in specific antimicrobial classes. This makes it easy to filter on isolates that were tested for e.g. any aminoglycoside, or to filter on carbapenem-resistant isolates without the need to specify the drugs.
|
||||
}
|
||||
\details{
|
||||
The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched for the input given in \code{ab_class} (case-insensitive). Next, \code{x} will be checked for column names with a value in any abbreviation, code or official name found in the \link{antibiotics} data set.
|
||||
All columns of \code{x} will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a filter function like e.g. \code{\link[=filter_aminoglycosides]{filter_aminoglycosides()}} will include column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
|
||||
}
|
||||
\section{Stable lifecycle}{
|
||||
|
||||
@ -103,3 +103,6 @@ example_isolates \%>\%
|
||||
filter_fluoroquinolones("R", "all")
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=antibiotic_class_selectors]{antibiotic_class_selectors()}} for the \code{select()} equivalent.
|
||||
}
|
||||
|
Reference in New Issue
Block a user