AMR/reference/antibiotic_class_selectors....

1101 lines
173 KiB
HTML
Raw Normal View History

2022-08-21 16:59:35 +02:00
<!DOCTYPE html>
2023-03-11 17:02:25 +01:00
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><meta name="description" content='These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class or group (according to the antibiotics data set), without the need to define the columns or antibiotic abbreviations.
2023-05-08 13:11:46 +02:00
In short, if you have a column name that resembles an antimicrobial drug, it will be picked up by any of these functions that matches its pharmaceutical class: "cefazolin", "kefzol", "CZO" and "J01DB04" will all be picked up by cephalosporins().'><title>Antibiotic Selectors — antibiotic_class_selectors • AMR (for R)</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.2.2/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.2.2/bootstrap.bundle.min.js"></script><link href="../deps/Fira_Code-0.4.6/font.css" rel="stylesheet"><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"><!-- bootstrap-toc --><script src="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@v1.0.1/dist/bootstrap-toc.min.js" integrity="sha256-4veVQbu7//Lk5TSmc7YV48MxtMy98e26cf5MrgZYnwo=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- search --><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- pkgdown --><script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet"><script src="../extra.js"></script><meta property="og:title" content="Antibiotic Selectors — antibiotic_class_selectors"><meta property="og:description" content='These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class or group (according to the antibiotics data set), without the need to define the columns or antibiotic abbreviations.
2023-03-11 17:02:25 +01:00
In short, if you have a column name that resembles an antimicrobial drug, it will be picked up by any of these functions that matches its pharmaceutical class: "cefazolin", "kefzol", "CZO" and "J01DB04" will all be picked up by cephalosporins().'><meta property="og:image" content="https://msberends.github.io/AMR/logo.svg"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:creator" content="@msberends"><meta name="twitter:site" content="@msberends"><!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
2022-08-21 16:59:35 +02:00
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--></head><body>
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
<nav class="navbar fixed-top navbar-dark navbar-expand-lg bg-primary"><div class="container">
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
2023-07-11 09:57:23 +02:00
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">2.0.0.9034</small>
2022-08-21 16:59:35 +02:00
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
2023-05-24 16:03:18 +02:00
<ul class="navbar-nav me-auto"><li class="nav-item dropdown">
2022-08-21 16:59:35 +02:00
<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" id="dropdown--how-to">
<span class="fa fa-question-circle"></span>
How to
</a>
<div class="dropdown-menu" aria-labelledby="dropdown--how-to">
<a class="dropdown-item" href="../articles/AMR.html">
<span class="fa fa-directions"></span>
2023-01-23 20:14:37 +01:00
Conduct AMR Analysis
2022-08-21 16:59:35 +02:00
</a>
2023-02-08 17:01:47 +01:00
<a class="dropdown-item" href="../reference/antibiogram.html">
<span class="fa fa-file-prescription"></span>
Generate Antibiogram (Trad./Syndromic/WISCA)
</a>
2022-08-21 16:59:35 +02:00
<a class="dropdown-item" href="../articles/resistance_predict.html">
<span class="fa fa-dice"></span>
2023-01-23 20:14:37 +01:00
Predict Antimicrobial Resistance
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/datasets.html">
<span class="fa fa-database"></span>
2023-02-26 21:34:01 +01:00
Download Data Sets for Own Use
</a>
<a class="dropdown-item" href="../reference/AMR-options.html">
<span class="fa fa-gear"></span>
Set User- Or Team-specific Package Settings
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/PCA.html">
<span class="fa fa-compress"></span>
2023-01-23 20:14:37 +01:00
Conduct Principal Component Analysis for AMR
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span>
2023-01-23 20:14:37 +01:00
Determine Multi-Drug Resistance (MDR)
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/WHONET.html">
<span class="fa fa-globe-americas"></span>
2023-01-23 20:14:37 +01:00
Work with WHONET Data
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/EUCAST.html">
<span class="fa fa-exchange-alt"></span>
2023-01-23 20:14:37 +01:00
Apply Eucast Rules
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../reference/mo_property.html">
<span class="fa fa-bug"></span>
2023-01-23 20:14:37 +01:00
Get Taxonomy of a Microorganism
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
2023-01-23 20:14:37 +01:00
Get Properties of an Antibiotic Drug
2022-08-21 16:59:35 +02:00
</a>
2022-11-13 08:54:32 +01:00
<a class="dropdown-item" href="../reference/av_property.html">
<span class="fa fa-capsules"></span>
2023-01-23 20:14:37 +01:00
Get Properties of an Antiviral Drug
2022-11-13 08:54:32 +01:00
</a>
2022-08-21 16:59:35 +02:00
</div>
</li>
2023-05-24 16:03:18 +02:00
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" id="dropdown--with-other-pkgs">
2023-05-27 10:53:23 +02:00
<span class="fa fa-layer-group"></span>
2023-05-24 16:03:18 +02:00
With other pkgs
</a>
<div class="dropdown-menu" aria-labelledby="dropdown--with-other-pkgs">
<a class="dropdown-item" href="../articles/other_pkg.html">
2023-05-27 10:53:23 +02:00
<span class="fa fa-layer-group"></span>
2023-05-24 16:03:18 +02:00
AMR &amp; dplyr/tidyverse
</a>
<a class="dropdown-item" href="../articles/other_pkg.html">
2023-05-27 10:53:23 +02:00
<span class="fa fa-layer-group"></span>
2023-05-24 16:03:18 +02:00
AMR &amp; data.table
</a>
<a class="dropdown-item" href="../articles/other_pkg.html">
2023-05-27 10:53:23 +02:00
<span class="fa fa-layer-group"></span>
2023-05-24 16:03:18 +02:00
AMR &amp; tidymodels
</a>
<a class="dropdown-item" href="../articles/other_pkg.html">
2023-05-27 10:53:23 +02:00
<span class="fa fa-layer-group"></span>
2023-05-24 16:03:18 +02:00
AMR &amp; base R
</a>
</div>
</li>
2022-08-21 16:59:35 +02:00
<li class="active nav-item">
<a class="nav-link" href="../reference/index.html">
<span class="fa fa-book-open"></span>
Manual
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../authors.html">
<span class="fa fa-users"></span>
Authors
</a>
</li>
2023-05-24 16:03:18 +02:00
</ul><form class="form-inline my-2 my-lg-0" role="search">
<input type="search" class="form-control me-sm-2" aria-label="Toggle navigation" name="search-input" data-search-index="../search.json" id="search-input" placeholder="Search for" autocomplete="off"></form>
<ul class="navbar-nav"><li class="nav-item">
2022-08-21 16:59:35 +02:00
<a class="nav-link" href="../news/index.html">
<span class="far fa far fa-newspaper"></span>
Changelog
</a>
</li>
2023-05-24 16:03:18 +02:00
<li class="nav-item">
2022-08-21 16:59:35 +02:00
<a class="external-link nav-link" href="https://github.com/msberends/AMR">
<span class="fab fa fab fa-github"></span>
Source Code
</a>
</li>
</ul></div>
</div>
</nav><div class="container template-reference-topic">
<div class="row">
<main id="main" class="col-md-9"><div class="page-header">
<img src="../logo.svg" class="logo" alt=""><h1>Antibiotic Selectors</h1>
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/HEAD/R/ab_selectors.R" class="external-link"><code>R/ab_selectors.R</code></a></small>
<div class="d-none name"><code>antibiotic_class_selectors.Rd</code></div>
</div>
<div class="ref-description section level2">
2023-03-11 17:02:25 +01:00
<p>These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class or group (according to the <a href="antibiotics.html">antibiotics</a> data set), without the need to define the columns or antibiotic abbreviations.</p>
<p>In short, if you have a column name that resembles an antimicrobial drug, it will be picked up by any of these functions that matches its pharmaceutical class: "cefazolin", "kefzol", "CZO" and "J01DB04" will all be picked up by <code>cephalosporins()</code>.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level2">
<h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
2023-01-21 23:53:21 +01:00
<div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">ab_class</span><span class="op">(</span><span class="va">ab_class</span>, only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, only_treatable <span class="op">=</span> <span class="cn">TRUE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">ab_selector</span><span class="op">(</span><span class="va">filter</span>, only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, only_treatable <span class="op">=</span> <span class="cn">TRUE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">aminoglycosides</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, only_treatable <span class="op">=</span> <span class="cn">TRUE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">aminopenicillins</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">antifungals</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">antimycobacterials</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">betalactams</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, only_treatable <span class="op">=</span> <span class="cn">TRUE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">carbapenems</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, only_treatable <span class="op">=</span> <span class="cn">TRUE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">cephalosporins</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">cephalosporins_1st</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">cephalosporins_2nd</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">cephalosporins_3rd</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">cephalosporins_4th</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">cephalosporins_5th</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">fluoroquinolones</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">glycopeptides</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">lincosamides</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">lipoglycopeptides</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">macrolides</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">oxazolidinones</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">penicillins</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">polymyxins</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, only_treatable <span class="op">=</span> <span class="cn">TRUE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">streptogramins</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">quinolones</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">tetracyclines</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">trimethoprims</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">ureidopenicillins</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">administrable_per_os</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-01-21 23:53:21 +01:00
<span><span class="fu">administrable_iv</span><span class="op">(</span>only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
<span><span class="fu">not_intrinsic_resistant</span><span class="op">(</span></span>
2023-01-21 23:53:21 +01:00
<span> only_sir_columns <span class="op">=</span> <span class="cn">FALSE</span>,</span>
2022-08-21 16:59:35 +02:00
<span> col_mo <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> version_expertrules <span class="op">=</span> <span class="fl">3.3</span>,</span>
<span> <span class="va">...</span></span>
<span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level2">
<h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>
<dl><dt>ab_class</dt>
<dd><p>an antimicrobial class or a part of it, such as <code>"carba"</code> and <code>"carbapenems"</code>. The columns <code>group</code>, <code>atc_group1</code> and <code>atc_group2</code> of the <a href="antibiotics.html">antibiotics</a> data set will be searched (case-insensitive) for this value.</p></dd>
2023-01-21 23:53:21 +01:00
<dt>only_sir_columns</dt>
2023-02-22 14:47:35 +01:00
<dd><p>a <a href="https://rdrr.io/r/base/logical.html" class="external-link">logical</a> to indicate whether only columns of class <code>sir</code> must be selected (default is <code>FALSE</code>), see <code><a href="as.sir.html">as.sir()</a></code></p></dd>
2022-08-21 16:59:35 +02:00
<dt>only_treatable</dt>
2023-02-22 14:47:35 +01:00
<dd><p>a <a href="https://rdrr.io/r/base/logical.html" class="external-link">logical</a> to indicate whether antimicrobial drugs should be excluded that are only for laboratory tests (default is <code>TRUE</code>), such as gentamicin-high (<code>GEH</code>) and imipenem/EDTA (<code>IPE</code>)</p></dd>
2022-08-21 16:59:35 +02:00
<dt>...</dt>
<dd><p>ignored, only in place to allow future extensions</p></dd>
<dt>filter</dt>
<dd><p>an <a href="https://rdrr.io/r/base/expression.html" class="external-link">expression</a> to be evaluated in the <a href="antibiotics.html">antibiotics</a> data set, such as <code>name %like% "trim"</code></p></dd>
<dt>col_mo</dt>
2023-02-22 14:47:35 +01:00
<dd><p>column name of the names or codes of the microorganisms (see <code><a href="as.mo.html">as.mo()</a></code>) - the default is the first column of class <code><a href="as.mo.html">mo</a></code>. Values will be coerced using <code><a href="as.mo.html">as.mo()</a></code>.</p></dd>
2022-08-21 16:59:35 +02:00
<dt>version_expertrules</dt>
2023-06-22 15:20:36 +02:00
<dd><p>the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be "3.3", "3.2", or "3.1".</p></dd>
2022-08-21 16:59:35 +02:00
</dl></div>
<div class="section level2">
<h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
<p>(internally) a <a href="https://rdrr.io/r/base/character.html" class="external-link">character</a> vector of column names, with additional class <code>"ab_selector"</code></p>
</div>
<div class="section level2">
<h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
2023-03-11 17:02:25 +01:00
<p>These functions can be used in data set calls for selecting columns and filtering rows. They work with base <span style="R">R</span>, the Tidyverse, and <code>data.table</code>. They are heavily inspired by the <a href="https://tidyselect.r-lib.org/reference/language.html" class="external-link">Tidyverse selection helpers</a> such as <code><a href="https://tidyselect.r-lib.org/reference/everything.html" class="external-link">everything()</a></code>, but are not limited to <code>dplyr</code> verbs. Nonetheless, they are very convenient to use with <code>dplyr</code> functions such as <code><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select()</a></code>, <code><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter()</a></code> and <code><a href="https://dplyr.tidyverse.org/reference/summarise.html" class="external-link">summarise()</a></code>, see <em>Examples</em>.</p>
2022-08-21 16:59:35 +02:00
<p>All columns in the data in which these functions are called will be searched for known antibiotic names, abbreviations, brand names, and codes (ATC, EARS-Net, WHO, etc.) according to the <a href="antibiotics.html">antibiotics</a> data set. This means that a selector such as <code>aminoglycosides()</code> will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.</p>
<p>The <code>ab_class()</code> function can be used to filter/select on a manually defined antibiotic class. It searches for results in the <a href="antibiotics.html">antibiotics</a> data set within the columns <code>group</code>, <code>atc_group1</code> and <code>atc_group2</code>.</p>
<p>The <code>ab_selector()</code> function can be used to internally filter the <a href="antibiotics.html">antibiotics</a> data set on any results, see <em>Examples</em>. It allows for filtering on a (part of) a certain name, and/or a group name or even a minimum of DDDs for oral treatment. This function yields the highest flexibility, but is also the least user-friendly, since it requires a hard-coded filter to set.</p>
<p>The <code>administrable_per_os()</code> and <code>administrable_iv()</code> functions also rely on the <a href="antibiotics.html">antibiotics</a> data set - antibiotic columns will be matched where a DDD (defined daily dose) for resp. oral and IV treatment is available in the <a href="antibiotics.html">antibiotics</a> data set.</p>
2023-07-10 16:52:49 +02:00
<p>The <code>not_intrinsic_resistant()</code> function can be used to only select antibiotic columns that pose no intrinsic resistance for the microorganisms in the data set. For example, if a data set contains only microorganism codes or names of <em>E. coli</em> and <em>K. pneumoniae</em> and contains a column "vancomycin", this column will be removed (or rather, unselected) using this function. It currently applies <a href="https://www.eucast.org/expert_rules_and_expected_phenotypes" class="external-link">'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.3</a> (2021) to determine intrinsic resistance, using the <code><a href="eucast_rules.html">eucast_rules()</a></code> function internally. Because of this determination, this function is quite slow in terms of performance.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level2">
<h2 id="full-list-of-supported-antibiotic-classes">Full list of supported (antibiotic) classes<a class="anchor" aria-label="anchor" href="#full-list-of-supported-antibiotic-classes"></a></h2>
2023-02-22 14:47:35 +01:00
<ul><li><p><code>aminoglycosides()</code> can select: <br> amikacin (AMK), amikacin/fosfomycin (AKF), amphotericin B-high (AMH), apramycin (APR), arbekacin (ARB), astromicin (AST), bekanamycin (BEK), dibekacin (DKB), framycetin (FRM), gentamicin (GEN), gentamicin-high (GEH), habekacin (HAB), hygromycin (HYG), isepamicin (ISE), kanamycin (KAN), kanamycin-high (KAH), kanamycin/cephalexin (KAC), micronomicin (MCR), neomycin (NEO), netilmicin (NET), pentisomicin (PIM), plazomicin (PLZ), propikacin (PKA), ribostamycin (RST), sisomicin (SIS), streptoduocin (STR), streptomycin (STR1), streptomycin-high (STH), tobramycin (TOB), and tobramycin-high (TOH)</p></li>
2022-08-21 16:59:35 +02:00
<li><p><code>aminopenicillins()</code> can select: <br> amoxicillin (AMX) and ampicillin (AMP)</p></li>
2023-02-22 14:47:35 +01:00
<li><p><code>antifungals()</code> can select: <br> amphotericin B (AMB), anidulafungin (ANI), butoconazole (BUT), caspofungin (CAS), ciclopirox (CIX), clotrimazole (CTR), econazole (ECO), fluconazole (FLU), flucytosine (FCT), fosfluconazole (FFL), griseofulvin (GRI), hachimycin (HCH), ibrexafungerp (IBX), isavuconazole (ISV), isoconazole (ISO), itraconazole (ITR), ketoconazole (KET), manogepix (MGX), micafungin (MIF), miconazole (MCZ), nystatin (NYS), oteseconazole (OTE), pimaricin (PMR), posaconazole (POS), rezafungin (RZF), ribociclib (RBC), sulconazole (SUC), terbinafine (TRB), terconazole (TRC), and voriconazole (VOR)</p></li>
<li><p><code>antimycobacterials()</code> can select: <br> 4-aminosalicylic acid (AMA), calcium aminosalicylate (CLA), capreomycin (CAP), clofazimine (CLF), delamanid (DLM), enviomycin (ENV), ethambutol (ETH), ethambutol/isoniazid (ETI), ethionamide (ETI1), isoniazid (INH), isoniazid/sulfamethoxazole/trimethoprim/pyridoxine (IST), morinamide (MRN), p-aminosalicylic acid (PAS), pretomanid (PMD), protionamide (PTH), pyrazinamide (PZA), rifabutin (RIB), rifampicin (RIF), rifampicin/ethambutol/isoniazid (REI), rifampicin/isoniazid (RFI), rifampicin/pyrazinamide/ethambutol/isoniazid (RPEI), rifampicin/pyrazinamide/isoniazid (RPI), rifamycin (RFM), rifapentine (RFP), simvastatin/fenofibrate (SMF), sodium aminosalicylate (SDA), streptomycin/isoniazid (STI), terizidone (TRZ), thioacetazone (TAT), thioacetazone/isoniazid (THI1), tiocarlide (TCR), and viomycin (VIO)</p></li>
<li><p><code>betalactams()</code> can select: <br> amoxicillin (AMX), amoxicillin/clavulanic acid (AMC), amoxicillin/sulbactam (AXS), ampicillin (AMP), ampicillin/sulbactam (SAM), apalcillin (APL), aspoxicillin (APX), avibactam (AVB), azidocillin (AZD), azlocillin (AZL), aztreonam (ATM), aztreonam/avibactam (AZA), aztreonam/nacubactam (ANC), bacampicillin (BAM), benzathine benzylpenicillin (BNB), benzathine phenoxymethylpenicillin (BNP), benzylpenicillin (PEN), biapenem (BIA), carbenicillin (CRB), carindacillin (CRN), cefacetrile (CAC), cefaclor (CEC), cefadroxil (CFR), cefalexin (LEX), cefaloridine (RID), cefalotin (CEP), cefamandole (MAN), cefapirin (HAP), cefatrizine (CTZ), cefazedone (CZD), cefazolin (CZO), cefcapene (CCP), cefcapene pivoxil (CCX), cefdinir (CDR), cefditoren (DIT), cefditoren pivoxil (DIX), cefepime (FEP), cefepime/clavulanic acid (CPC), cefepime/nacubactam (FNC), cefepime/tazobactam (FPT), cefetamet (CAT), cefetamet pivoxil (CPI), cefetecol (CCL), cefetrizole (CZL), cefixime (CFM), cefmenoxime (CMX), cefmetazole (CMZ), cefodizime (DIZ), cefonicid (CID), cefoperazone (CFP), cefoperazone/sulbactam (CSL), ceforanide (CND), cefoselis (CSE), cefotaxime (CTX), cefotaxime/clavulanic acid (CTC), cefotaxime/sulbactam (CTS), cefotetan (CTT), cefotiam (CTF), cefotiam hexetil (CHE), cefovecin (FOV), cefoxitin (FOX), cefoxitin screening (FOX1), cefozopran (ZOP), cefpimizole (CFZ), cefpiramide (CPM), cefpirome (CPO), cefpodoxime (CPD), cefpodoxime proxetil (CPX), cefpodoxime/clavulanic acid (CDC), cefprozil (CPR), cefquinome (CEQ), cefroxadine (CRD), cefsulodin (CFS), cefsumide (CSU), ceftaroline (CPT), ceftaroline/avibactam (CPA), ceftazidime (CAZ), ceftazidime/avibactam (CZA), ceftazidime/clavulanic acid (CCV), cefteram (CEM), cefteram pivoxil (CPL), ceftezole (CTL), ceftibuten (CTB), ceftiofur (TIO), ceftizoxime (CZX), ceftizoxime alapivoxil (CZP), ceftobiprole (BPR), ceftobiprole medocaril (CFM1), ceftolozane/tazobactam (CZT), ceftriaxone (CRO), ceftriaxone/beta-lactamase inhibitor (CEB), cefuroxime (CXM), cefuroxime axetil (CXA), cephradine (CED), ciclacillin (CIC), clometocillin (CLM), cloxacillin (CLO), dicloxacillin (DIC), doripenem (DOR), epicillin (EPC), ertapenem (ETP), flucloxacillin (FLC), hetacillin (HET), imipenem (IPM), imipenem/EDTA (IPE), imipenem/relebactam (IMR), latamoxef (LTM), lenampicillin (LEN), loracarbef (LOR), mecillinam (MEC), meropenem (MEM), meropenem/nacubactam (MNC), meropenem/vaborbactam (MEV), metampicillin (MTM), meticillin (MET), mezlocillin (MEZ), mezlocillin/sulbactam (MSU), nacubactam (NAC), nafcillin (NAF), oxacillin (OXA), panipenem (PAN), penamecillin (PNM), penicillin/novobiocin (PNO), penicillin/sulbactam (PSU), pheneticillin (PHE), phenoxymethylpenicillin (PHN), piperacillin (PIP), piperacillin/sulbactam (PIS), piperacillin/tazobactam (TZP), piridicillin (PRC), pivampicillin (PVM), pivmecillinam (PME), procaine benzylpenicillin (PRB), propicillin (PRP), razupenem (RZM), ritipenem (RIT), ritipenem acoxil (RIA), sarmoxicillin (SRX), sulbactam (SUL), sulbenicillin (SBC), sultamicillin (SLT6), talampicillin (TAL), tazobactam (TAZ), tebipenem (TBP), temocillin (TEM), ticarcillin (TIC), and ticarcillin/clavulanic acid (TCC)</p></li>
<li><p><code>carbapenems()</code> can select: <br> biapenem (BIA), doripenem (DOR), ertapenem (ETP), imipenem (IPM), imipenem/EDTA (IPE), imipenem/relebactam (IMR), meropenem (MEM), meropenem/nacubactam (MNC), meropenem/vaborbactam (MEV), panipenem (PAN), razupenem (RZM), ritipenem (RIT), ritipenem acoxil (RIA), and tebipenem (TBP)</p></li>
<li><p><code>cephalosporins()</code> can select: <br> cefacetrile (CAC), cefaclor (CEC), cefadroxil (CFR), cefalexin (LEX), cefaloridine (RID), cefalotin (CEP), cefamandole (MAN), cefapirin (HAP), cefatrizine (CTZ), cefazedone (CZD), cefazolin (CZO), cefcapene (CCP), cefcapene pivoxil (CCX), cefdinir (CDR), cefditoren (DIT), cefditoren pivoxil (DIX), cefepime (FEP), cefepime/clavulanic acid (CPC), cefepime/tazobactam (FPT), cefetamet (CAT), cefetamet pivoxil (CPI), cefetecol (CCL), cefetrizole (CZL), cefixime (CFM), cefmenoxime (CMX), cefmetazole (CMZ), cefodizime (DIZ), cefonicid (CID), cefoperazone (CFP), cefoperazone/sulbactam (CSL), ceforanide (CND), cefoselis (CSE), cefotaxime (CTX), cefotaxime/clavulanic acid (CTC), cefotaxime/sulbactam (CTS), cefotetan (CTT), cefotiam (CTF), cefotiam hexetil (CHE), cefovecin (FOV), cefoxitin (FOX), cefoxitin screening (FOX1), cefozopran (ZOP), cefpimizole (CFZ), cefpiramide (CPM), cefpirome (CPO), cefpodoxime (CPD), cefpodoxime proxetil (CPX), cefpodoxime/clavulanic acid (CDC), cefprozil (CPR), cefquinome (CEQ), cefroxadine (CRD), cefsulodin (CFS), cefsumide (CSU), ceftaroline (CPT), ceftaroline/avibactam (CPA), ceftazidime (CAZ), ceftazidime/avibactam (CZA), ceftazidime/clavulanic acid (CCV), cefteram (CEM), cefteram pivoxil (CPL), ceftezole (CTL), ceftibuten (CTB), ceftiofur (TIO), ceftizoxime (CZX), ceftizoxime alapivoxil (CZP), ceftobiprole (BPR), ceftobiprole medocaril (CFM1), ceftolozane/tazobactam (CZT), ceftriaxone (CRO), ceftriaxone/beta-lactamase inhibitor (CEB), cefuroxime (CXM), cefuroxime axetil (CXA), cephradine (CED), latamoxef (LTM), and loracarbef (LOR)</p></li>
<li><p><code>cephalosporins_1st()</code> can select: <br> cefacetrile (CAC), cefadroxil (CFR), cefalexin (LEX), cefaloridine (RID), cefalotin (CEP), cefapirin (HAP), cefatrizine (CTZ), cefazedone (CZD), cefazolin (CZO), cefroxadine (CRD), ceftezole (CTL), and cephradine (CED)</p></li>
<li><p><code>cephalosporins_2nd()</code> can select: <br> cefaclor (CEC), cefamandole (MAN), cefmetazole (CMZ), cefonicid (CID), ceforanide (CND), cefotetan (CTT), cefotiam (CTF), cefoxitin (FOX), cefoxitin screening (FOX1), cefprozil (CPR), cefuroxime (CXM), cefuroxime axetil (CXA), and loracarbef (LOR)</p></li>
<li><p><code>cephalosporins_3rd()</code> can select: <br> cefcapene (CCP), cefcapene pivoxil (CCX), cefdinir (CDR), cefditoren (DIT), cefditoren pivoxil (DIX), cefetamet (CAT), cefetamet pivoxil (CPI), cefixime (CFM), cefmenoxime (CMX), cefodizime (DIZ), cefoperazone (CFP), cefoperazone/sulbactam (CSL), cefotaxime (CTX), cefotaxime/clavulanic acid (CTC), cefotaxime/sulbactam (CTS), cefotiam hexetil (CHE), cefovecin (FOV), cefpimizole (CFZ), cefpiramide (CPM), cefpodoxime (CPD), cefpodoxime proxetil (CPX), cefpodoxime/clavulanic acid (CDC), cefsulodin (CFS), ceftazidime (CAZ), ceftazidime/avibactam (CZA), ceftazidime/clavulanic acid (CCV), cefteram (CEM), cefteram pivoxil (CPL), ceftibuten (CTB), ceftiofur (TIO), ceftizoxime (CZX), ceftizoxime alapivoxil (CZP), ceftriaxone (CRO), ceftriaxone/beta-lactamase inhibitor (CEB), and latamoxef (LTM)</p></li>
<li><p><code>cephalosporins_4th()</code> can select: <br> cefepime (FEP), cefepime/clavulanic acid (CPC), cefepime/tazobactam (FPT), cefetecol (CCL), cefoselis (CSE), cefozopran (ZOP), cefpirome (CPO), and cefquinome (CEQ)</p></li>
<li><p><code>cephalosporins_5th()</code> can select: <br> ceftaroline (CPT), ceftaroline/avibactam (CPA), ceftobiprole (BPR), ceftobiprole medocaril (CFM1), and ceftolozane/tazobactam (CZT)</p></li>
<li><p><code>fluoroquinolones()</code> can select: <br> besifloxacin (BES), ciprofloxacin (CIP), clinafloxacin (CLX), danofloxacin (DAN), delafloxacin (DFX), difloxacin (DIF), enoxacin (ENX), enrofloxacin (ENR), finafloxacin (FIN), fleroxacin (FLE), garenoxacin (GRN), gatifloxacin (GAT), gemifloxacin (GEM), grepafloxacin (GRX), lascufloxacin (LSC), levofloxacin (LVX), levonadifloxacin (LND), lomefloxacin (LOM), marbofloxacin (MAR), metioxate (MXT), miloxacin (MIL), moxifloxacin (MFX), nadifloxacin (NAD), nifuroquine (NIF), norfloxacin (NOR), ofloxacin (OFX), orbifloxacin (ORB), pazufloxacin (PAZ), pefloxacin (PEF), pradofloxacin (PRA), premafloxacin (PRX), prulifloxacin (PRU), rufloxacin (RFL), sarafloxacin (SAR), sitafloxacin (SIT), sparfloxacin (SPX), temafloxacin (TMX), tilbroquinol (TBQ), tioxacin (TXC), tosufloxacin (TFX), and trovafloxacin (TVA)</p></li>
<li><p><code>glycopeptides()</code> can select: <br> avoparcin (AVO), dalbavancin (DAL), norvancomycin (NVA), oritavancin (ORI), ramoplanin (RAM), teicoplanin (TEC), teicoplanin-macromethod (TCM), telavancin (TLV), vancomycin (VAN), and vancomycin-macromethod (VAM)</p></li>
<li><p><code>lincosamides()</code> can select: <br> acetylmidecamycin (ACM), acetylspiramycin (ASP), clindamycin (CLI), gamithromycin (GAM), kitasamycin (KIT), lincomycin (LIN), meleumycin (MEL), nafithromycin (ZWK), pirlimycin (PRL), primycin (PRM), solithromycin (SOL), tildipirosin (TIP), tilmicosin (TIL), tulathromycin (TUL), tylosin (TYL), and tylvalosin (TYL1)</p></li>
<li><p><code>lipoglycopeptides()</code> can select: <br> dalbavancin (DAL), oritavancin (ORI), and telavancin (TLV)</p></li>
<li><p><code>macrolides()</code> can select: <br> acetylmidecamycin (ACM), acetylspiramycin (ASP), azithromycin (AZM), clarithromycin (CLR), dirithromycin (DIR), erythromycin (ERY), flurithromycin (FLR1), gamithromycin (GAM), josamycin (JOS), kitasamycin (KIT), meleumycin (MEL), midecamycin (MID), miocamycin (MCM), nafithromycin (ZWK), oleandomycin (OLE), pirlimycin (PRL), primycin (PRM), rokitamycin (ROK), roxithromycin (RXT), solithromycin (SOL), spiramycin (SPI), telithromycin (TLT), tildipirosin (TIP), tilmicosin (TIL), troleandomycin (TRL), tulathromycin (TUL), tylosin (TYL), and tylvalosin (TYL1)</p></li>
<li><p><code>oxazolidinones()</code> can select: <br> cadazolid (CDZ), cycloserine (CYC), linezolid (LNZ), tedizolid (TZD), and thiacetazone (THA)</p></li>
<li><p><code>penicillins()</code> can select: <br> amoxicillin (AMX), amoxicillin/clavulanic acid (AMC), amoxicillin/sulbactam (AXS), ampicillin (AMP), ampicillin/sulbactam (SAM), apalcillin (APL), aspoxicillin (APX), avibactam (AVB), azidocillin (AZD), azlocillin (AZL), aztreonam (ATM), aztreonam/avibactam (AZA), aztreonam/nacubactam (ANC), bacampicillin (BAM), benzathine benzylpenicillin (BNB), benzathine phenoxymethylpenicillin (BNP), benzylpenicillin (PEN), carbenicillin (CRB), carindacillin (CRN), cefepime/nacubactam (FNC), ciclacillin (CIC), clometocillin (CLM), cloxacillin (CLO), dicloxacillin (DIC), epicillin (EPC), flucloxacillin (FLC), hetacillin (HET), lenampicillin (LEN), mecillinam (MEC), metampicillin (MTM), meticillin (MET), mezlocillin (MEZ), mezlocillin/sulbactam (MSU), nacubactam (NAC), nafcillin (NAF), oxacillin (OXA), penamecillin (PNM), penicillin/novobiocin (PNO), penicillin/sulbactam (PSU), pheneticillin (PHE), phenoxymethylpenicillin (PHN), piperacillin (PIP), piperacillin/sulbactam (PIS), piperacillin/tazobactam (TZP), piridicillin (PRC), pivampicillin (PVM), pivmecillinam (PME), procaine benzylpenicillin (PRB), propicillin (PRP), sarmoxicillin (SRX), sulbactam (SUL), sulbenicillin (SBC), sultamicillin (SLT6), talampicillin (TAL), tazobactam (TAZ), temocillin (TEM), ticarcillin (TIC), and ticarcillin/clavulanic acid (TCC)</p></li>
<li><p><code>polymyxins()</code> can select: <br> colistin (COL), polymyxin B (PLB), and polymyxin B/polysorbate 80 (POP)</p></li>
<li><p><code>quinolones()</code> can select: <br> besifloxacin (BES), cinoxacin (CIN), ciprofloxacin (CIP), clinafloxacin (CLX), danofloxacin (DAN), delafloxacin (DFX), difloxacin (DIF), enoxacin (ENX), enrofloxacin (ENR), finafloxacin (FIN), fleroxacin (FLE), flumequine (FLM), garenoxacin (GRN), gatifloxacin (GAT), gemifloxacin (GEM), grepafloxacin (GRX), lascufloxacin (LSC), levofloxacin (LVX), levonadifloxacin (LND), lomefloxacin (LOM), marbofloxacin (MAR), metioxate (MXT), miloxacin (MIL), moxifloxacin (MFX), nadifloxacin (NAD), nalidixic acid (NAL), nemonoxacin (NEM), nifuroquine (NIF), nitroxoline (NTR), norfloxacin (NOR), ofloxacin (OFX), orbifloxacin (ORB), oxolinic acid (OXO), pazufloxacin (PAZ), pefloxacin (PEF), pipemidic acid (PPA), piromidic acid (PIR), pradofloxacin (PRA), premafloxacin (PRX), prulifloxacin (PRU), rosoxacin (ROS), rufloxacin (RFL), sarafloxacin (SAR), sitafloxacin (SIT), sparfloxacin (SPX), temafloxacin (TMX), tilbroquinol (TBQ), tioxacin (TXC), tosufloxacin (TFX), and trovafloxacin (TVA)</p></li>
2022-08-21 16:59:35 +02:00
<li><p><code>streptogramins()</code> can select: <br> pristinamycin (PRI) and quinupristin/dalfopristin (QDA)</p></li>
2023-02-22 14:47:35 +01:00
<li><p><code>tetracyclines()</code> can select: <br> cetocycline (CTO), chlortetracycline (CTE), clomocycline (CLM1), demeclocycline (DEM), doxycycline (DOX), eravacycline (ERV), lymecycline (LYM), metacycline (MTC), minocycline (MNO), omadacycline (OMC), oxytetracycline (OXY), penimepicycline (PNM1), rolitetracycline (RLT), sarecycline (SRC), tetracycline (TCY), and tigecycline (TGC)</p></li>
<li><p><code>trimethoprims()</code> can select: <br> brodimoprim (BDP), sulfadiazine (SDI), sulfadiazine/tetroxoprim (SLT), sulfadiazine/trimethoprim (SLT1), sulfadimethoxine (SUD), sulfadimidine (SDM), sulfadimidine/trimethoprim (SLT2), sulfafurazole (SLF), sulfaisodimidine (SLF1), sulfalene (SLF2), sulfamazone (SZO), sulfamerazine (SLF3), sulfamerazine/trimethoprim (SLT3), sulfamethizole (SLF4), sulfamethoxazole (SMX), sulfamethoxypyridazine (SLF5), sulfametomidine (SLF6), sulfametoxydiazine (SLF7), sulfametrole/trimethoprim (SLT4), sulfamoxole (SLF8), sulfamoxole/trimethoprim (SLT5), sulfanilamide (SLF9), sulfaperin (SLF10), sulfaphenazole (SLF11), sulfapyridine (SLF12), sulfathiazole (SUT), sulfathiourea (SLF13), trimethoprim (TMP), and trimethoprim/sulfamethoxazole (SXT)</p></li>
<li><p><code>ureidopenicillins()</code> can select: <br> azlocillin (AZL), mezlocillin (MEZ), piperacillin (PIP), and piperacillin/tazobactam (TZP)</p></li>
2022-08-21 16:59:35 +02:00
</ul></div>
<div class="section level2">
<h2 id="reference-data-publicly-available">Reference Data Publicly Available<a class="anchor" aria-label="anchor" href="#reference-data-publicly-available"></a></h2>
2023-01-21 23:53:21 +01:00
<p>All data sets in this <code>AMR</code> package (about microorganisms, antibiotics, SIR interpretation, EUCAST rules, etc.) are publicly and freely available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. We also provide tab-separated plain text files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please visit <a href="https://msberends.github.io/AMR/articles/datasets.html">our website for the download links</a>. The actual files are of course available on <a href="https://github.com/msberends/AMR/tree/main/data-raw" class="external-link">our GitHub repository</a>.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level2">
<h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
<div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span><span class="co"># `example_isolates` is a data set available in the AMR package.</span></span></span>
<span class="r-in"><span><span class="co"># See ?example_isolates.</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2,000 × 46</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> date patient age gender ward mo PEN OXA FLC AMX </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> 2002-01-02 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> 2002-01-03 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> 2002-01-16 067927 45 F ICU B_STPHY_EPDR R NA R NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> 2002-01-17 858515 79 F ICU B_STPHY_EPDR R NA S NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1,990 more rows</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TOB &lt;sir&gt;, AMK &lt;sir&gt;, KAN &lt;sir&gt;, TMP &lt;sir&gt;, SXT &lt;sir&gt;, NIT &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># FOS &lt;sir&gt;, LNZ &lt;sir&gt;, CIP &lt;sir&gt;, MFX &lt;sir&gt;, VAN &lt;sir&gt;, TEC &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TCY &lt;sir&gt;, TGC &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;, AZM &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># IPM &lt;sir&gt;, MEM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, MUP &lt;sir&gt;, …</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># Examples sections below are split into 'base R', 'dplyr', and 'data.table':</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span><span class="co"># base R ------------------------------------------------------------------</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># select columns 'IPM' (imipenem) and 'MEM' (meropenem)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span><span class="op">[</span>, <span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span><span class="op">]</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
2022-08-21 16:59:35 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2,000 × 2</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> IPM MEM </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1,990 more rows</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span><span class="op">[</span>, <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"mo"</span>, <span class="fu">aminoglycosides</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">]</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2,000 × 5</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> mo GEN TOB AMK KAN </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> B_ESCHR_COLI NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> B_ESCHR_COLI NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> B_STPHY_EPDR NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> B_STPHY_EPDR NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> B_STPHY_EPDR NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> B_STPHY_EPDR NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> B_STPHY_AURS NA S NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> B_STPHY_AURS NA S NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> B_STPHY_EPDR NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> B_STPHY_EPDR NA NA NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1,990 more rows</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># select only antibiotic columns with DDDs for oral treatment</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span><span class="op">[</span>, <span class="fu">administrable_per_os</span><span class="op">(</span><span class="op">)</span><span class="op">]</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For administrable_per_os() using columns 'OXA' (oxacillin), 'FLC'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (flucloxacillin), 'AMX' (amoxicillin), 'AMC' (amoxicillin/clavulanic acid),</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> 'AMP' (ampicillin), 'CXM' (cefuroxime), 'KAN' (kanamycin), 'TMP'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (trimethoprim), 'NIT' (nitrofurantoin), 'FOS' (fosfomycin), 'LNZ'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (linezolid), 'CIP' (ciprofloxacin), 'MFX' (moxifloxacin), 'VAN'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (vancomycin), 'TCY' (tetracycline), 'DOX' (doxycycline), 'ERY'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (erythromycin), 'CLI' (clindamycin), 'AZM' (azithromycin), 'MTR'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (metronidazole), 'CHL' (chloramphenicol), 'COL' (colistin), and 'RIF'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (rifampicin)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2,000 × 23</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> OXA FLC AMX AMC AMP CXM KAN TMP NIT FOS LNZ CIP MFX </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> NA NA NA I NA I NA R NA NA R NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> NA NA NA I NA I NA R NA NA R NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> NA R NA NA NA R NA S NA NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> NA R NA NA NA R NA S NA NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> NA R NA NA NA R NA R NA NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> NA R NA NA NA R NA R NA NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> NA S R S R S NA R NA NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> NA S R S R S NA R NA NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> NA R NA NA NA R NA S NA NA NA S NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> NA S NA NA NA S NA S NA NA NA S NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1,990 more rows</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 10 more variables: VAN &lt;sir&gt;, TCY &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># AZM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, RIF &lt;sir&gt;</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># filter using any() or all()</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/any.html" class="external-link">any</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span>, <span class="op">]</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 55 × 46</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> date patient age gender ward mo PEN OXA FLC AMX </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> 2004-06-09 529296 69 M ICU B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> 2004-06-09 529296 69 M ICU B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> 2004-11-03 D65308 80 F ICU B_STNTR_MLTP R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> 2005-04-21 452212 82 F ICU B_ENTRC NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> 2005-04-22 452212 82 F ICU B_ENTRC NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> 2005-04-22 452212 82 F ICU B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> 2007-02-21 8BBC46 61 F Clinical B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> 2007-12-15 401043 72 M Clinical B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> 2008-01-22 1710B8 82 M Clinical B_PROTS_MRBL R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> 2008-01-22 1710B8 82 M Clinical B_PROTS_MRBL R NA NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 45 more rows</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TOB &lt;sir&gt;, AMK &lt;sir&gt;, KAN &lt;sir&gt;, TMP &lt;sir&gt;, SXT &lt;sir&gt;, NIT &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># FOS &lt;sir&gt;, LNZ &lt;sir&gt;, CIP &lt;sir&gt;, MFX &lt;sir&gt;, VAN &lt;sir&gt;, TEC &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TCY &lt;sir&gt;, TGC &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;, AZM &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># IPM &lt;sir&gt;, MEM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, MUP &lt;sir&gt;, …</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/base/subset.html" class="external-link">subset</a></span><span class="op">(</span><span class="va">example_isolates</span>, <span class="fu"><a href="https://rdrr.io/r/base/any.html" class="external-link">any</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span><span class="op">)</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 55 × 46</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> date patient age gender ward mo PEN OXA FLC AMX </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> 2004-06-09 529296 69 M ICU B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> 2004-06-09 529296 69 M ICU B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> 2004-11-03 D65308 80 F ICU B_STNTR_MLTP R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> 2005-04-21 452212 82 F ICU B_ENTRC NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> 2005-04-22 452212 82 F ICU B_ENTRC NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> 2005-04-22 452212 82 F ICU B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> 2007-02-21 8BBC46 61 F Clinical B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> 2007-12-15 401043 72 M Clinical B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> 2008-01-22 1710B8 82 M Clinical B_PROTS_MRBL R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> 2008-01-22 1710B8 82 M Clinical B_PROTS_MRBL R NA NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 45 more rows</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TOB &lt;sir&gt;, AMK &lt;sir&gt;, KAN &lt;sir&gt;, TMP &lt;sir&gt;, SXT &lt;sir&gt;, NIT &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># FOS &lt;sir&gt;, LNZ &lt;sir&gt;, CIP &lt;sir&gt;, MFX &lt;sir&gt;, VAN &lt;sir&gt;, TEC &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TCY &lt;sir&gt;, TGC &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;, AZM &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># IPM &lt;sir&gt;, MEM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, MUP &lt;sir&gt;, …</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># filter on any or all results in the carbapenem columns (i.e., IPM, MEM):</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/any.html" class="external-link">any</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>, <span class="op">]</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
2023-01-21 23:53:21 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> Filtering any of columns 'IPM' and 'MEM' to contain value "S", "I" or "R"</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 962 × 46</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> date patient age gender ward mo PEN OXA FLC AMX </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> 2002-01-19 738003 71 M Clinical B_ESCHR_COLI R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> 2002-01-19 738003 71 M Clinical B_ESCHR_COLI R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> 2002-01-22 F35553 50 M ICU B_PROTS_MRBL R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> 2002-01-22 F35553 50 M ICU B_PROTS_MRBL R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> 2002-02-05 067927 45 F ICU B_SERRT_MRCS R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> 2002-02-05 067927 45 F ICU B_SERRT_MRCS R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> 2002-02-05 067927 45 F ICU B_SERRT_MRCS R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> 2002-02-27 066895 85 F Clinical B_KLBSL_PNMN R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> 2002-02-27 066895 85 F Clinical B_KLBSL_PNMN R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> 2002-03-08 4FC193 69 M Clinical B_ESCHR_COLI R NA NA R </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 952 more rows</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TOB &lt;sir&gt;, AMK &lt;sir&gt;, KAN &lt;sir&gt;, TMP &lt;sir&gt;, SXT &lt;sir&gt;, NIT &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># FOS &lt;sir&gt;, LNZ &lt;sir&gt;, CIP &lt;sir&gt;, MFX &lt;sir&gt;, VAN &lt;sir&gt;, TEC &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TCY &lt;sir&gt;, TGC &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;, AZM &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># IPM &lt;sir&gt;, MEM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, MUP &lt;sir&gt;, …</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/all.html" class="external-link">all</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>, <span class="op">]</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
2023-01-21 23:53:21 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> Filtering all of columns 'IPM' and 'MEM' to contain value "S", "I" or "R"</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 756 × 46</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> date patient age gender ward mo PEN OXA FLC AMX </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> 2002-04-14 F30196 73 M Outpat… B_STRPT_GRPB S NA S S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> 2003-04-08 114570 74 M ICU B_STRPT_PYGN S NA S S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> 2003-04-08 114570 74 M ICU B_STRPT_GRPA S NA S S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> 2003-04-08 114570 74 M ICU B_STRPT_GRPA S NA S S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> 2003-08-14 F71508 0 F Clinic… B_STRPT_GRPB S NA S S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> 2003-10-16 650870 63 F ICU B_ESCHR_COLI R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> 2003-10-20 F35553 52 M ICU B_ENTRBC_CLOC R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> 2003-10-20 F35553 52 M ICU B_ENTRBC_CLOC R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> 2003-11-04 2FC253 87 F ICU B_ESCHR_COLI R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> 2003-11-04 2FC253 87 F ICU B_ESCHR_COLI R NA NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 746 more rows</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TOB &lt;sir&gt;, AMK &lt;sir&gt;, KAN &lt;sir&gt;, TMP &lt;sir&gt;, SXT &lt;sir&gt;, NIT &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># FOS &lt;sir&gt;, LNZ &lt;sir&gt;, CIP &lt;sir&gt;, MFX &lt;sir&gt;, VAN &lt;sir&gt;, TEC &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TCY &lt;sir&gt;, TGC &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;, AZM &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># IPM &lt;sir&gt;, MEM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, MUP &lt;sir&gt;, …</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># filter with multiple antibiotic selectors using c()</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/all.html" class="external-link">all</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span>, <span class="fu">aminoglycosides</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span>, <span class="op">]</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 26 × 46</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> date patient age gender ward mo PEN OXA FLC AMX </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> 2004-11-03 D65308 80 F ICU B_STNTR_MLTP R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> 2005-04-22 452212 82 F ICU B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> 2007-02-21 8BBC46 61 F Clinical B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> 2007-12-15 401043 72 M Clinical B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> 2008-12-06 501361 43 F Clinical B_STNTR_MLTP R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> 2011-05-09 207325 82 F ICU B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> 2012-03-12 582258 80 M ICU B_STPHY_CONS R R R R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> 2012-05-19 C25552 89 F Outpati… B_STPHY_CONS R R R R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> 2012-07-17 F05015 83 M ICU B_STPHY_CONS R R R R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> 2012-07-20 404299 66 F Clinical B_STPHY_CONS R R R R </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 16 more rows</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TOB &lt;sir&gt;, AMK &lt;sir&gt;, KAN &lt;sir&gt;, TMP &lt;sir&gt;, SXT &lt;sir&gt;, NIT &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># FOS &lt;sir&gt;, LNZ &lt;sir&gt;, CIP &lt;sir&gt;, MFX &lt;sir&gt;, VAN &lt;sir&gt;, TEC &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TCY &lt;sir&gt;, TGC &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;, AZM &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># IPM &lt;sir&gt;, MEM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, MUP &lt;sir&gt;, …</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-in"><span><span class="co"># filter + select in one go: get penicillins in carbapenem-resistant strains</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/any.html" class="external-link">any</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span>, <span class="fu">penicillins</span><span class="op">(</span><span class="op">)</span><span class="op">]</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> For penicillins() using columns 'PEN' (benzylpenicillin), 'OXA'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (oxacillin), 'FLC' (flucloxacillin), 'AMX' (amoxicillin), 'AMC'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (amoxicillin/clavulanic acid), 'AMP' (ampicillin), and 'TZP'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (piperacillin/tazobactam)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 55 × 7</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> PEN OXA FLC AMX AMC AMP TZP </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> NA NA NA NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> NA NA NA NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> R NA NA R R R R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> NA NA NA NA NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> NA NA NA NA NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> NA NA NA NA NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> NA NA NA NA NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> NA NA NA NA NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> R NA NA NA S NA S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> R NA NA NA S NA S </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 45 more rows</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># You can combine selectors with '&amp;' to be more specific. For example,</span></span></span>
<span class="r-in"><span><span class="co"># penicillins() would select benzylpenicillin ('peni G') and</span></span></span>
<span class="r-in"><span><span class="co"># administrable_per_os() would select erythromycin. Yet, when combined these</span></span></span>
<span class="r-in"><span><span class="co"># drugs are both omitted since benzylpenicillin is not administrable per os</span></span></span>
<span class="r-in"><span><span class="co"># and erythromycin is not a penicillin:</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span><span class="op">[</span>, <span class="fu">penicillins</span><span class="op">(</span><span class="op">)</span> <span class="op">&amp;</span> <span class="fu">administrable_per_os</span><span class="op">(</span><span class="op">)</span><span class="op">]</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For penicillins() using columns 'PEN' (benzylpenicillin), 'OXA'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (oxacillin), 'FLC' (flucloxacillin), 'AMX' (amoxicillin), 'AMC'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (amoxicillin/clavulanic acid), 'AMP' (ampicillin), and 'TZP'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (piperacillin/tazobactam)</span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For administrable_per_os() using columns 'OXA' (oxacillin), 'FLC'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (flucloxacillin), 'AMX' (amoxicillin), 'AMC' (amoxicillin/clavulanic acid),</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> 'AMP' (ampicillin), 'CXM' (cefuroxime), 'KAN' (kanamycin), 'TMP'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (trimethoprim), 'NIT' (nitrofurantoin), 'FOS' (fosfomycin), 'LNZ'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (linezolid), 'CIP' (ciprofloxacin), 'MFX' (moxifloxacin), 'VAN'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (vancomycin), 'TCY' (tetracycline), 'DOX' (doxycycline), 'ERY'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (erythromycin), 'CLI' (clindamycin), 'AZM' (azithromycin), 'MTR'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (metronidazole), 'CHL' (chloramphenicol), 'COL' (colistin), and 'RIF'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (rifampicin)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2,000 × 5</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> OXA FLC AMX AMC AMP </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> NA NA NA I NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> NA NA NA I NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> NA R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> NA R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> NA R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> NA R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> NA S R S R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> NA S R S R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> NA R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> NA S NA NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1,990 more rows</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-in"><span><span class="co"># ab_selector() applies a filter in the `antibiotics` data set and is thus</span></span></span>
<span class="r-in"><span><span class="co"># very flexible. For instance, to select antibiotic columns with an oral DDD</span></span></span>
<span class="r-in"><span><span class="co"># of at least 1 gram:</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="va">example_isolates</span><span class="op">[</span>, <span class="fu">ab_selector</span><span class="op">(</span><span class="va">oral_ddd</span> <span class="op">&gt;</span> <span class="fl">1</span> <span class="op">&amp;</span> <span class="va">oral_units</span> <span class="op">==</span> <span class="st">"g"</span><span class="op">)</span><span class="op">]</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For ab_selector(oral_ddd &gt; 1 &amp; oral_units == "g") using columns 'OXA'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (oxacillin), 'FLC' (flucloxacillin), 'AMX' (amoxicillin), 'AMC'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (amoxicillin/clavulanic acid), 'AMP' (ampicillin), 'KAN' (kanamycin), 'FOS'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (fosfomycin), 'LNZ' (linezolid), 'VAN' (vancomycin), 'ERY' (erythromycin),</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> 'CLI' (clindamycin), 'MTR' (metronidazole), and 'CHL' (chloramphenicol)</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2,000 × 13</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> OXA FLC AMX AMC AMP KAN FOS LNZ VAN ERY CLI MTR CHL </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> NA NA NA I NA NA NA R R R R NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> NA NA NA I NA NA NA R R R R NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> NA R NA NA NA NA NA NA S R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> NA R NA NA NA NA NA NA S R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> NA R NA NA NA NA NA NA S R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> NA R NA NA NA NA NA NA S R R NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> NA S R S R NA NA NA S S NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> NA S R S R NA NA NA S S NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> NA R NA NA NA NA NA NA S R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> NA S NA NA NA NA NA NA S S NA NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1,990 more rows</span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># \donttest{</span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-in"><span><span class="co"># dplyr -------------------------------------------------------------------</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://tibble.tidyverse.org/reference/tibble.html" class="external-link">tibble</a></span><span class="op">(</span>kefzol <span class="op">=</span> <span class="fu"><a href="random.html">random_sir</a></span><span class="op">(</span><span class="fl">5</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="fu">cephalosporins</span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> For cephalosporins() using column 'kefzol' (cefazolin)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 5 × 1</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> kefzol</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> </span>
2023-07-11 09:57:23 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">1</span> R </span>
2023-07-10 17:09:18 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">2</span> I </span>
2023-07-11 09:57:23 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">3</span> I </span>
2023-07-10 19:13:17 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">4</span> I </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">5</span> R </span>
2023-03-11 17:02:25 +01:00
<span class="r-in"><span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span> <span class="co"># get AMR for all aminoglycosides e.g., per ward:</span></span></span>
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">ward</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise.html" class="external-link">summarise</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/across.html" class="external-link">across</a></span><span class="op">(</span><span class="fu">aminoglycosides</span><span class="op">(</span><span class="op">)</span>, <span class="va">resistance</span><span class="op">)</span><span class="op">)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span>
2023-02-08 17:01:47 +01:00
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span class="warning">Warning: </span>There was 1 warning in `summarise()`.</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span style="color: #00BBBB;"></span> In argument: `across(aminoglycosides(), resistance)`.</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span style="color: #00BBBB;"></span> In group 3: `ward = "Outpatient"`.</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> Caused by warning:</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span style="color: #BBBB00;">!</span> Introducing NA: only 23 results available for KAN in group: ward =</span>
2022-11-24 20:37:19 +01:00
<span class="r-wrn co"><span class="r-pr">#&gt;</span> "Outpatient" (minimum = 30).</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 3 × 5</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> ward GEN TOB AMK KAN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">1</span> Clinical 0.229 0.315 0.626 1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">2</span> ICU 0.290 0.400 0.662 1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">3</span> Outpatient 0.2 0.368 0.605 <span style="color: #BB0000;">NA</span></span>
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="co"># You can combine selectors with '&amp;' to be more specific:</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="fu">penicillins</span><span class="op">(</span><span class="op">)</span> <span class="op">&amp;</span> <span class="fu">administrable_per_os</span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For penicillins() using columns 'PEN' (benzylpenicillin), 'OXA'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (oxacillin), 'FLC' (flucloxacillin), 'AMX' (amoxicillin), 'AMC'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (amoxicillin/clavulanic acid), 'AMP' (ampicillin), and 'TZP'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (piperacillin/tazobactam)</span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For administrable_per_os() using columns 'OXA' (oxacillin), 'FLC'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (flucloxacillin), 'AMX' (amoxicillin), 'AMC' (amoxicillin/clavulanic acid),</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> 'AMP' (ampicillin), 'CXM' (cefuroxime), 'KAN' (kanamycin), 'TMP'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (trimethoprim), 'NIT' (nitrofurantoin), 'FOS' (fosfomycin), 'LNZ'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (linezolid), 'CIP' (ciprofloxacin), 'MFX' (moxifloxacin), 'VAN'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (vancomycin), 'TCY' (tetracycline), 'DOX' (doxycycline), 'ERY'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (erythromycin), 'CLI' (clindamycin), 'AZM' (azithromycin), 'MTR'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (metronidazole), 'CHL' (chloramphenicol), 'COL' (colistin), and 'RIF'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (rifampicin)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2,000 × 5</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> OXA FLC AMX AMC AMP </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> NA NA NA I NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> NA NA NA I NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> NA R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> NA R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> NA R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> NA R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> NA S R S R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> NA S R S R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> NA R NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> NA S NA NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1,990 more rows</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="co"># get AMR for only drugs that matter - no intrinsic resistance:</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu"><a href="mo_property.html">mo_genus</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://rdrr.io/r/base/match.html" class="external-link">%in%</a></span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"Escherichia"</span>, <span class="st">"Klebsiella"</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">ward</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise.html" class="external-link">summarise</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/across.html" class="external-link">across</a></span><span class="op">(</span><span class="fu">not_intrinsic_resistant</span><span class="op">(</span><span class="op">)</span>, <span class="va">resistance</span><span class="op">)</span><span class="op">)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> Using column 'mo' as input for mo_genus()</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> For not_intrinsic_resistant() removing columns 'PEN'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (benzylpenicillin), 'LNZ' (linezolid), 'VAN' (vancomycin), 'TEC'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (teicoplanin), 'ERY' (erythromycin), 'CLI' (clindamycin), 'AZM'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (azithromycin), and 'RIF' (rifampicin)</span>
2023-02-08 17:01:47 +01:00
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span class="warning">Warning: </span>There were 52 warnings in `summarise()`.</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> The first warning was:</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span style="color: #00BBBB;"></span> In argument: `across(not_intrinsic_resistant(), resistance)`.</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span style="color: #00BBBB;"></span> In group 1: `ward = "Clinical"`.</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> Caused by warning:</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span style="color: #BBBB00;">!</span> Introducing NA: no results available for OXA in group: ward = "Clinical"</span>
2022-11-24 20:37:19 +01:00
<span class="r-wrn co"><span class="r-pr">#&gt;</span> (minimum = 30).</span>
2023-02-08 17:01:47 +01:00
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span style="color: #00BBBB;"></span> Run `dplyr::last_dplyr_warnings()` to see the 51 remaining warnings.</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 3 × 33</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> ward OXA FLC AMX AMC AMP TZP CZO FEP CXM FOX</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">1</span> Clin… <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> 0.606 0.121 0.606 0.050<span style="text-decoration: underline;">4</span> 0.065<span style="text-decoration: underline;">6</span> 0.015<span style="text-decoration: underline;">9</span> 0.062<span style="text-decoration: underline;">2</span> 0.064<span style="text-decoration: underline;">8</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">2</span> ICU <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> 0.535 0.172 0.535 0.119 <span style="color: #BB0000;">NA</span> 0.072<span style="text-decoration: underline;">2</span> 0.082<span style="text-decoration: underline;">8</span> 0.099<span style="text-decoration: underline;">2</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">3</span> Outp… <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> <span style="color: #BB0000;">NA</span> </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 22 more variables: CTX &lt;dbl&gt;, CAZ &lt;dbl&gt;, CRO &lt;dbl&gt;, GEN &lt;dbl&gt;, TOB &lt;dbl&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># AMK &lt;dbl&gt;, KAN &lt;dbl&gt;, TMP &lt;dbl&gt;, SXT &lt;dbl&gt;, NIT &lt;dbl&gt;, FOS &lt;dbl&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># CIP &lt;dbl&gt;, MFX &lt;dbl&gt;, TCY &lt;dbl&gt;, TGC &lt;dbl&gt;, DOX &lt;dbl&gt;, IPM &lt;dbl&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># MEM &lt;dbl&gt;, MTR &lt;dbl&gt;, CHL &lt;dbl&gt;, COL &lt;dbl&gt;, MUP &lt;dbl&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="co"># get susceptibility for antibiotics whose name contains "trim":</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu"><a href="first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">ward</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise.html" class="external-link">summarise</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/across.html" class="external-link">across</a></span><span class="op">(</span><span class="fu">ab_selector</span><span class="op">(</span><span class="va">name</span> <span class="op"><a href="like.html">%like%</a></span> <span class="st">"trim"</span><span class="op">)</span>, <span class="va">susceptibility</span><span class="op">)</span><span class="op">)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For ab_selector(name %like% "trim") using columns 'TMP' (trimethoprim)</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> and 'SXT' (trimethoprim/sulfamethoxazole)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 3 × 3</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> ward TMP SXT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span></span>
2023-02-10 16:26:36 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">1</span> Clinical 0.627 0.808</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">2</span> ICU 0.549 0.778</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">3</span> Outpatient 0.667 0.821</span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="co"># this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2,000 × 2</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> IPM MEM </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1,990 more rows</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="co"># this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="va">mo</span>, <span class="fu">aminoglycosides</span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2,000 × 5</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> mo GEN TOB AMK KAN </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> B_ESCHR_COLI NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> B_ESCHR_COLI NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> B_STPHY_EPDR NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> B_STPHY_EPDR NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> B_STPHY_EPDR NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> B_STPHY_EPDR NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> B_STPHY_AURS NA S NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> B_STPHY_AURS NA S NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> B_STPHY_EPDR NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> B_STPHY_EPDR NA NA NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1,990 more rows</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="co"># any() and all() work in dplyr's filter() too:</span></span></span>
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://rdrr.io/r/base/any.html" class="external-link">any</a></span><span class="op">(</span><span class="fu">aminoglycosides</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span> <span class="fu"><a href="https://rdrr.io/r/base/all.html" class="external-link">all</a></span><span class="op">(</span><span class="fu">cephalosporins_2nd</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span></span></span>
<span class="r-in"><span> <span class="op">)</span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For cephalosporins_2nd() using columns 'CXM' (cefuroxime) and 'FOX'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (cefoxitin)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 112 × 46</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> date patient age gender ward mo PEN OXA FLC AMX </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> 2002-02-21 4FC193 69 M Clinical B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> 2002-03-16 4FC193 69 M Clinical B_PSDMN_AERG R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> 2002-04-08 130252 78 M ICU B_ENTRC_FCLS NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> 2002-06-23 798871 82 M Clinical B_ENTRC_FCLS NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> 2002-06-23 798871 82 M Clinical B_ENTRC_FCLS NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> 2002-07-21 955940 82 F Clinical B_PSDMN_AERG R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> 2002-07-21 955940 82 F Clinical B_PSDMN_AERG R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> 2003-08-13 F35553 52 M ICU B_ENTRC_FCLS NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> 2003-09-05 F35553 52 M ICU B_ENTRC_FCLS NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> 2004-06-09 529296 69 M ICU B_ENTRC_FACM NA NA NA NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 102 more rows</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TOB &lt;sir&gt;, AMK &lt;sir&gt;, KAN &lt;sir&gt;, TMP &lt;sir&gt;, SXT &lt;sir&gt;, NIT &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># FOS &lt;sir&gt;, LNZ &lt;sir&gt;, CIP &lt;sir&gt;, MFX &lt;sir&gt;, VAN &lt;sir&gt;, TEC &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TCY &lt;sir&gt;, TGC &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;, AZM &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># IPM &lt;sir&gt;, MEM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, MUP &lt;sir&gt;, …</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="co"># also works with c():</span></span></span>
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/any.html" class="external-link">any</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span>, <span class="fu">aminoglycosides</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span><span class="op">)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 531 × 46</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> date patient age gender ward mo PEN OXA FLC AMX </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> 2002-02-21 4FC193 69 M Clinical B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> 2002-03-16 4FC193 69 M Clinical B_PSDMN_AERG R NA NA R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> 2002-03-17 B30560 78 M Clinical B_STPHY_CONS R NA R R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> 2002-04-04 E61143 67 M Clinical B_STRPT_SNGN S NA NA S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> 2002-04-08 130252 78 M ICU B_ENTRC_FCLS NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> 2002-04-14 F30196 73 M Outpati… B_STRPT_GRPB S NA S S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> 2002-05-07 D91570 83 M Clinical B_STPHY_CONS R NA R R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> 2002-05-07 D91570 83 M Clinical B_STPHY_CONS R NA R R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> 2002-05-14 077552 86 F Clinical B_STRPT_PNMN S NA NA S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> 2002-05-14 077552 86 F Clinical B_STRPT_PNMN S NA NA S </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 521 more rows</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TOB &lt;sir&gt;, AMK &lt;sir&gt;, KAN &lt;sir&gt;, TMP &lt;sir&gt;, SXT &lt;sir&gt;, NIT &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># FOS &lt;sir&gt;, LNZ &lt;sir&gt;, CIP &lt;sir&gt;, MFX &lt;sir&gt;, VAN &lt;sir&gt;, TEC &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TCY &lt;sir&gt;, TGC &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;, AZM &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># IPM &lt;sir&gt;, MEM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, MUP &lt;sir&gt;, …</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="co"># not setting any/all will automatically apply all():</span></span></span>
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu">aminoglycosides</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span>
2023-02-22 14:47:35 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> Assuming a filter on all 4 aminoglycosides. Wrap around all() or</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> any() to prevent this note.</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 427 × 46</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> date patient age gender ward mo PEN OXA FLC AMX </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> 2002-02-21 4FC193 69 M Clinical B_ENTRC_FACM NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> 2002-03-17 B30560 78 M Clinical B_STPHY_CONS R NA R R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> 2002-04-04 E61143 67 M Clinical B_STRPT_SNGN S NA NA S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> 2002-04-08 130252 78 M ICU B_ENTRC_FCLS NA NA NA NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> 2002-04-14 F30196 73 M Outpati… B_STRPT_GRPB S NA S S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> 2002-05-07 D91570 83 M Clinical B_STPHY_CONS R NA R R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> 2002-05-07 D91570 83 M Clinical B_STPHY_CONS R NA R R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> 2002-05-14 077552 86 F Clinical B_STRPT_PNMN S NA NA S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> 2002-05-14 077552 86 F Clinical B_STRPT_PNMN S NA NA S </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> 2002-05-16 D25302 65 F ICU B_STRPT_ANGN S NA NA S </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 417 more rows</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TOB &lt;sir&gt;, AMK &lt;sir&gt;, KAN &lt;sir&gt;, TMP &lt;sir&gt;, SXT &lt;sir&gt;, NIT &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># FOS &lt;sir&gt;, LNZ &lt;sir&gt;, CIP &lt;sir&gt;, MFX &lt;sir&gt;, VAN &lt;sir&gt;, TEC &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># TCY &lt;sir&gt;, TGC &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;, AZM &lt;sir&gt;,</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># IPM &lt;sir&gt;, MEM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, MUP &lt;sir&gt;, …</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="co"># this will select columns 'mo' and all antimycobacterial drugs ('RIF'):</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="va">mo</span>, <span class="fu">ab_class</span><span class="op">(</span><span class="st">"mycobact"</span><span class="op">)</span><span class="op">)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2023-01-05 14:53:59 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For ab_class("mycobact") using column 'RIF' (rifampicin)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2,000 × 2</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> mo RIF </span>
2023-01-21 23:53:21 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span>
2023-01-05 14:53:59 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 1</span> B_ESCHR_COLI R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 2</span> B_ESCHR_COLI R </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 3</span> B_STPHY_EPDR NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 4</span> B_STPHY_EPDR NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 5</span> B_STPHY_EPDR NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 6</span> B_STPHY_EPDR NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 7</span> B_STPHY_AURS NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 8</span> B_STPHY_AURS NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;"> 9</span> B_STPHY_EPDR NA </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">10</span> B_STPHY_EPDR NA </span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1,990 more rows</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="co"># get bug/drug combinations for only glycopeptides in Gram-positives:</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu"><a href="mo_property.html">mo_is_gram_positive</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="va">mo</span>, <span class="fu">glycopeptides</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span> <span class="fu"><a href="bug_drug_combinations.html">bug_drug_combinations</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://rdrr.io/r/base/format.html" class="external-link">format</a></span><span class="op">(</span><span class="op">)</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> Using column 'mo' as input for mo_is_gram_positive()</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> For glycopeptides() using columns 'VAN' (vancomycin) and 'TEC'</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> (teicoplanin)</span>
2023-02-12 11:30:57 +01:00
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 2 × 8</span></span>
2023-04-14 11:23:10 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> Group Drug CoNS `E. faecalis` `S. aureus` `S. epidermidis` `S. hominis`</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">1</span> <span style="color: #949494;">"</span>Glycopep… Teic… <span style="color: #949494;">""</span> <span style="color: #949494;">""</span> <span style="color: #949494;">"</span> 0.0% (0/… <span style="color: #949494;">"</span>64.1% (25/39)<span style="color: #949494;">"</span> <span style="color: #949494;">"</span> 6.8% (4/5…</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">2</span> <span style="color: #949494;">""</span> Vanc… <span style="color: #949494;">"</span> 0.… <span style="color: #949494;">"</span> 0.0% (0/39… <span style="color: #949494;">"</span> 0.0% (0/… <span style="color: #949494;">"</span> 0.0% (0/171)<span style="color: #949494;">"</span> <span style="color: #949494;">"</span> 0.0% (0/8…</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># 1 more variable: `S. pneumoniae` &lt;chr&gt;</span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span></span></span>
<span class="r-in"><span> some_column <span class="op">=</span> <span class="st">"some_value"</span>,</span></span>
<span class="r-in"><span> J01CA01 <span class="op">=</span> <span class="st">"S"</span></span></span>
<span class="r-in"><span> <span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="co"># ATC code of ampicillin</span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="fu">penicillins</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="co"># only the 'J01CA01' column will be selected</span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For penicillins() using column 'J01CA01' (ampicillin)</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> J01CA01</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1 S</span>
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://dplyr.tidyverse.org" class="external-link">"dplyr"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
2023-03-12 13:10:15 +01:00
<span class="r-in"><span> <span class="co"># with recent versions of dplyr, this is all equal:</span></span></span>
2022-08-28 22:45:38 +02:00
<span class="r-in"><span> <span class="va">x</span> <span class="op">&lt;-</span> <span class="va">example_isolates</span><span class="op">[</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span>, <span class="op">]</span></span></span>
<span class="r-in"><span> <span class="va">y</span> <span class="op">&lt;-</span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span></span></span>
<span class="r-in"><span> <span class="va">z</span> <span class="op">&lt;-</span> <span class="va">example_isolates</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/across.html" class="external-link">if_all</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span>, <span class="op">~</span> <span class="va">.x</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span> <span class="fu"><a href="https://rdrr.io/r/base/identical.html" class="external-link">identical</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span><span class="op">)</span> <span class="op">&amp;&amp;</span> <span class="fu"><a href="https://rdrr.io/r/base/identical.html" class="external-link">identical</a></span><span class="op">(</span><span class="va">y</span>, <span class="va">z</span><span class="op">)</span></span></span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span><span class="op">}</span></span></span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> Assuming a filter on all 2 carbapenems. Wrap around all() or any() to</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> prevent this note.</span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> Assuming a filter on all 2 carbapenems. Wrap around all() or any() to</span>
2022-08-28 22:45:38 +02:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> prevent this note.</span>
2022-11-24 20:37:19 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
2022-08-28 22:45:38 +02:00
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] TRUE</span>
2023-03-11 17:02:25 +01:00
<span class="r-in"><span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># data.table --------------------------------------------------------------</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># data.table is supported as well, just use it in the same way as with</span></span></span>
2023-03-12 13:10:15 +01:00
<span class="r-in"><span><span class="co"># base R, but add `with = FALSE` if using a single AB selector.</span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://r-datatable.com" class="external-link">"data.table"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="va">dt</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://Rdatatable.gitlab.io/data.table/reference/as.data.table.html" class="external-link">as.data.table</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
2023-03-12 13:10:15 +01:00
<span class="r-in"><span> <span class="co"># this does not work, it returns column *names*</span></span></span>
<span class="r-in"><span> <span class="va">dt</span><span class="op">[</span>, <span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span><span class="op">]</span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-in"><span><span class="op">}</span></span></span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> Loading required package: data.table</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> </span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> Attaching package: data.table</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> The following objects are masked from package:dplyr:</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> </span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> between, first, last</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> The following objects are masked from package:AMR:</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> </span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> %like%, like</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] "IPM" "MEM"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> attr(,"class")</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] "ab_selector" "character" </span>
2023-03-12 13:10:15 +01:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://r-datatable.com" class="external-link">"data.table"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="co"># so `with = FALSE` is required</span></span></span>
<span class="r-in"><span> <span class="va">dt</span><span class="op">[</span>, <span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span>, with <span class="op">=</span> <span class="cn">FALSE</span><span class="op">]</span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> IPM MEM</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1: &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2: &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3: &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4: &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5: &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> --- </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1996: &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1997: S S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1998: S S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1999: S S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2000: S S</span>
2023-03-12 13:10:15 +01:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># for multiple selections or AB selectors, `with = FALSE` is not needed:</span></span></span>
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://r-datatable.com" class="external-link">"data.table"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="va">dt</span><span class="op">[</span>, <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"mo"</span>, <span class="fu">aminoglycosides</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">]</span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> mo GEN TOB AMK KAN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1: B_ESCHR_COLI &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2: B_ESCHR_COLI &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3: B_STPHY_EPDR &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4: B_STPHY_EPDR &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5: B_STPHY_EPDR &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> --- </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1996: B_STRPT_PNMN R R R R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1997: B_ESCHR_COLI S S S &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1998: B_STPHY_CONS S &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1999: B_ESCHR_COLI S S &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2000: B_KLBSL_PNMN S S &lt;NA&gt; &lt;NA&gt;</span>
2023-03-12 13:10:15 +01:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://r-datatable.com" class="external-link">"data.table"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="va">dt</span><span class="op">[</span>, <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span>, <span class="fu">aminoglycosides</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">]</span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> IPM MEM GEN TOB AMK KAN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1: &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2: &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3: &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4: &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5: &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> --- </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1996: &lt;NA&gt; &lt;NA&gt; R R R R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1997: S S S S S &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1998: S S S &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1999: S S S S &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2000: S S S S &lt;NA&gt; &lt;NA&gt;</span>
2023-03-12 13:10:15 +01:00
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># row filters are also supported:</span></span></span>
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://r-datatable.com" class="external-link">"data.table"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="va">dt</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/any.html" class="external-link">any</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"S"</span><span class="op">)</span>, <span class="op">]</span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> date patient age gender ward mo PEN OXA FLC AMX</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1: 2002-01-19 738003 71 M Clinical B_ESCHR_COLI R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2: 2002-01-19 738003 71 M Clinical B_ESCHR_COLI R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3: 2002-01-22 F35553 50 M ICU B_PROTS_MRBL R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4: 2002-01-22 F35553 50 M ICU B_PROTS_MRBL R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5: 2002-02-05 067927 45 F ICU B_SERRT_MRCS R &lt;NA&gt; &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> --- </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 905: 2005-04-12 D71461 70 M ICU B_ESCHR_COLI R &lt;NA&gt; &lt;NA&gt; S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 906: 2009-11-12 650870 69 F Outpatient B_ESCHR_COLI R &lt;NA&gt; &lt;NA&gt; S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 907: 2012-06-14 8CBCF2 41 F Clinical B_STPHY_CONS R S S &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 908: 2012-10-11 175532 78 M Clinical B_ESCHR_COLI R &lt;NA&gt; &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 909: 2013-11-23 A97263 77 M Clinical B_KLBSL_PNMN R &lt;NA&gt; &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> AMC AMP TZP CZO FEP CXM FOX CTX CAZ CRO GEN TOB AMK KAN TMP</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1: I &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; S &lt;NA&gt; S &lt;NA&gt; S &lt;NA&gt; S &lt;NA&gt; &lt;NA&gt; S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2: I &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; S &lt;NA&gt; S &lt;NA&gt; S &lt;NA&gt; S &lt;NA&gt; &lt;NA&gt; S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3: I &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; S &lt;NA&gt; S S S &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4: I &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; S &lt;NA&gt; S S S &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5: R R &lt;NA&gt; R &lt;NA&gt; R R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> --- </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 905: S S S &lt;NA&gt; S S S S S S S S S &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 906: S S S S S S S S S S S S S &lt;NA&gt; S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 907: S &lt;NA&gt; &lt;NA&gt; S S S S S R S S &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 908: S R S &lt;NA&gt; S R R S S S S S &lt;NA&gt; &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 909: S R S &lt;NA&gt; S S S S S S S S &lt;NA&gt; &lt;NA&gt; S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> SXT NIT FOS LNZ CIP MFX VAN TEC TCY TGC DOX ERY CLI AZM IPM MEM</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1: S &lt;NA&gt; &lt;NA&gt; R &lt;NA&gt; &lt;NA&gt; R R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; R R R S &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2: S &lt;NA&gt; &lt;NA&gt; R &lt;NA&gt; &lt;NA&gt; R R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; R R R S &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3: S R &lt;NA&gt; R S &lt;NA&gt; R R R R R R R R S &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4: S R &lt;NA&gt; R S &lt;NA&gt; R R R R R R R R S &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5: S R &lt;NA&gt; R S &lt;NA&gt; R R R R R R R R S &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> --- </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 905: S S &lt;NA&gt; R S &lt;NA&gt; R R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; R R R S S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 906: S S &lt;NA&gt; R S &lt;NA&gt; R R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; R R R S S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 907: S &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; S &lt;NA&gt; S &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; S S S S S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 908: R R &lt;NA&gt; R R R R R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; R R R S S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 909: S S &lt;NA&gt; R S &lt;NA&gt; R R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; R R R S S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> MTR CHL COL MUP RIF</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1: &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2: &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3: &lt;NA&gt; &lt;NA&gt; R &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4: &lt;NA&gt; &lt;NA&gt; R &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5: &lt;NA&gt; &lt;NA&gt; R &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> --- </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 905: &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 906: &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 907: &lt;NA&gt; &lt;NA&gt; R &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 908: &lt;NA&gt; &lt;NA&gt; S &lt;NA&gt; R</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 909: &lt;NA&gt; &lt;NA&gt; S &lt;NA&gt; R</span>
2023-03-12 13:10:15 +01:00
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="st"><a href="https://r-datatable.com" class="external-link">"data.table"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="va">dt</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/any.html" class="external-link">any</a></span><span class="op">(</span><span class="fu">carbapenems</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"S"</span><span class="op">)</span>, <span class="fu">penicillins</span><span class="op">(</span><span class="op">)</span>, with <span class="op">=</span> <span class="cn">FALSE</span><span class="op">]</span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
2023-03-11 17:02:25 +01:00
<span class="r-msg co"><span class="r-pr">#&gt;</span> For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> For penicillins() using columns 'PEN' (benzylpenicillin), 'OXA'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (oxacillin), 'FLC' (flucloxacillin), 'AMX' (amoxicillin), 'AMC'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (amoxicillin/clavulanic acid), 'AMP' (ampicillin), and 'TZP'</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> (piperacillin/tazobactam)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> PEN OXA FLC AMX AMC AMP TZP</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1: R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; I &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2: R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; I &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3: R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; I &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4: R &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; I &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5: R &lt;NA&gt; &lt;NA&gt; R R R &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> --- </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 905: R &lt;NA&gt; &lt;NA&gt; S S S S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 906: R &lt;NA&gt; &lt;NA&gt; S S S S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 907: R S S &lt;NA&gt; S &lt;NA&gt; &lt;NA&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 908: R &lt;NA&gt; &lt;NA&gt; R S R S</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 909: R &lt;NA&gt; &lt;NA&gt; R S R S</span>
2022-08-21 16:59:35 +02:00
<span class="r-in"><span><span class="co"># }</span></span></span>
</code></pre></div>
</div>
</main><aside class="col-md-3"><nav id="toc"><h2>On this page</h2>
</nav></aside></div>
<footer><div class="pkgdown-footer-left">
2022-12-11 11:50:34 +01:00
<p></p><p><code>AMR</code> (for R). Free and open-source, licenced under the <a target="_blank" href="https://github.com/msberends/AMR/blob/main/LICENSE" class="external-link">GNU General Public License version 2.0 (GPL-2)</a>.<br>Developed at the <a target="_blank" href="https://www.rug.nl" class="external-link">University of Groningen</a> and <a target="_blank" href="https://www.umcg.nl" class="external-link">University Medical Center Groningen</a> in The Netherlands.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="pkgdown-footer-right">
2022-12-11 11:50:34 +01:00
<p></p><p><a target="_blank" href="https://www.rug.nl" class="external-link"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/logos/logo_rug.svg" style="max-width: 150px;"></a><a target="_blank" href="https://www.umcg.nl" class="external-link"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/logos/logo_umcg.svg" style="max-width: 150px;"></a></p>
2022-08-21 16:59:35 +02:00
</div>
</footer></div>
</body></html>