1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 20:46:11 +01:00

(v1.8.0.9010) as.mo improvement

This commit is contained in:
dr. M.S. (Matthijs) Berends 2022-03-15 17:35:02 +01:00
parent 0fb9a1b194
commit 7b0f1596bd
13 changed files with 76 additions and 41 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 1.8.1
Date: 2022-03-14
Version: 1.8.0.9010
Date: 2022-03-15
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
data analysis and to work with microbial and antimicrobial properties by

View File

@ -1,5 +1,5 @@
# `AMR` 1.8.1
# `AMR` 1.8.0.9010
## <small>Last updated: 15 March 2022</small>
All functions in this package are considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months.
@ -14,6 +14,7 @@ All functions in this package are considered to be stable. Updates to the AMR in
* More informative warning messages
* Added 192 as valid MIC
* Updated MIC printing in tibbles
* Increased speed for loading the package
### Other
* Fix for unit testing on R 3.3

View File

@ -243,7 +243,7 @@ droplevels.mic <- function(x, exclude = if (any(is.na(levels(x)))) NULL else NA,
pillar_shaft.mic <- function(x, ...) {
crude_numbers <- as.double(x)
operators <- gsub("[^<=>]+", "", as.character(x))
operators[operators != ""] <- font_silver(operators[operators != ""], collapse = NULL)
operators[!is.na(operators) & operators != ""] <- font_silver(operators[!is.na(operators) & operators != ""], collapse = NULL)
out <- trimws(paste0(operators, trimws(format(crude_numbers))))
out[is.na(x)] <- font_na(NA)
# maketrailing zeroes almost invisible

29
R/mo.R
View File

@ -1003,6 +1003,35 @@ exec_as.mo <- function(x,
}
}
# try splitting of characters in the middle and then find ID based on old names ----
# only when text length is 6 or lower
# like esco = E. coli, klpn = K. pneumoniae, stau = S. aureus, staaur = S. aureus
if (nchar(g.x_backup_without_spp) <= 6) {
x_length <- nchar(g.x_backup_without_spp)
x_split <- paste0("^",
g.x_backup_without_spp %pm>% substr(1, x_length / 2),
".* ",
g.x_backup_without_spp %pm>% substr((x_length / 2) + 1, x_length))
found <- lookup(fullname_lower %like_case% x_split,
haystack = MO.old_lookup,
column = NULL)
if (!all(is.na(found))) {
# it's an old name, so return it
if (property == "ref") {
x[i] <- found["ref"]
} else {
x[i] <- lookup(fullname == found["fullname_new"], haystack = MO_lookup)
}
pkg_env$mo_renamed_last_run <- found["fullname"]
was_renamed(name_old = found["fullname"],
name_new = lookup(fullname == found["fullname_new"], "fullname", haystack = MO_lookup),
ref_old = found["ref"],
ref_new = lookup(fullname == found["fullname_new"], "ref", haystack = MO_lookup),
mo = lookup(fullname == found["fullname_new"], "mo", haystack = MO_lookup))
return(x[i])
}
}
# try fullname without start and without nchar limit of >= 6 ----
# like "K. pneu rhino" >> "Klebsiella pneumoniae (rhinoscleromatis)" = KLEPNERH
found <- lookup(fullname_lower %like_case% e.x_withspaces_start_only,

Binary file not shown.

View File

@ -43,7 +43,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="https://msberends.github.io/AMR/index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.1</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9010</span>
</span>
</div>

View File

@ -17,7 +17,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.1</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9010</span>
</span>
</div>

View File

@ -44,7 +44,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.1</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9010</span>
</span>
</div>
@ -190,7 +190,7 @@
<div class="page-header toc-ignore">
<h1 data-toc-skip>Data sets for download / own use</h1>
<h4 data-toc-skip class="date">14 March 2022</h4>
<h4 data-toc-skip class="date">15 March 2022</h4>
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/HEAD/vignettes/datasets.Rmd" class="external-link"><code>vignettes/datasets.Rmd</code></a></small>
<div class="hidden name"><code>datasets.Rmd</code></div>

View File

@ -17,7 +17,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.1</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9010</span>
</span>
</div>

View File

@ -47,7 +47,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.1</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9010</span>
</span>
</div>

View File

@ -17,7 +17,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.1</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9010</span>
</span>
</div>
@ -157,14 +157,16 @@
</div>
<div class="section level2">
<h2 class="page-header" data-toc-text="1.8.1" id="amr-181">
<code>AMR</code> 1.8.1<a class="anchor" aria-label="anchor" href="#amr-181"></a></h2>
<h2 class="page-header" data-toc-text="1.8.0.9010" id="amr-1809010">
<code>AMR</code> 1.8.0.9010<a class="anchor" aria-label="anchor" href="#amr-1809010"></a></h2>
<div class="section level3">
<h3 id="last-updated-march-1-8-0-9010"><small>Last updated: 15 March 2022</small><a class="anchor" aria-label="anchor" href="#last-updated-march-1-8-0-9010"></a></h3>
<p>All functions in this package are considered to be stable. Updates to
the AMR interpretation rules (such as by EUCAST and CLSI), the microbial
taxonomy, and the antibiotic dosages will all be updated every 6 to 12
months.</p>
<div class="section level4">
<h4 id="changed-1-8-1">Changed<a class="anchor" aria-label="anchor" href="#changed-1-8-1"></a></h4>
<h4 id="changed-1-8-0-9010">Changed<a class="anchor" aria-label="anchor" href="#changed-1-8-0-9010"></a></h4>
<ul><li><p>Fix for using <code><a href="../reference/as.rsi.html">as.rsi()</a></code> on values containing capped
values (such as <code>&gt;=</code>), sometimes leading to
<code>NA</code></p></li>
@ -182,12 +184,14 @@ ignoring non-taxonomic text, such as:</p>
<li><p>More informative warning messages</p></li>
<li><p>Added 192 as valid MIC</p></li>
<li><p>Updated MIC printing in tibbles</p></li>
<li><p>Increased speed for loading the package</p></li>
</ul></div>
<div class="section level4">
<h4 id="other-1-8-1">Other<a class="anchor" aria-label="anchor" href="#other-1-8-1"></a></h4>
<h4 id="other-1-8-0-9010">Other<a class="anchor" aria-label="anchor" href="#other-1-8-0-9010"></a></h4>
<ul><li>Fix for unit testing on R 3.3</li>
<li>Fix for size of some image elements, as requested by CRAN</li>
</ul></div>
</div>
</div>
<div class="section level2">
<h2 class="page-header" data-toc-text="1.8.0" id="amr-180">
@ -368,7 +372,7 @@ guideline</li>
<li>Improved plot legends for MICs and disk diffusion values</li>
<li>Improved speed of <code><a href="../reference/as.ab.html">as.ab()</a></code> and all <code>ab_*()</code>
functions</li>
<li>Added <code><a href="https://ggplot2.tidyverse.org/reference/fortify.html" class="external-link">fortify()</a></code> extensions for plotting methods</li>
<li>Added <code>fortify()</code> extensions for plotting methods</li>
<li>
<code>NA</code> values of the classes <code>&lt;mic&gt;</code>,
<code>&lt;disk&gt;</code> and <code>&lt;rsi&gt;</code> are now exported
@ -484,7 +488,7 @@ rewritten.</li>
selector and function <code>filter_betalactams()</code> as additional
antbiotic column filter. The group of betalactams consists of all
carbapenems, cephalosporins and penicillins.</li>
<li>A <code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot()</a></code> method for
<li>A <code>ggplot()</code> method for
<code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>
</li>
</ul></div>
@ -628,7 +632,7 @@ function) to select/filter on e.g. linezolid and tedizolid</p>
<li><p>Support for custom MDRO guidelines, using the new
<code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function, please see
<code><a href="../reference/mdro.html">mdro()</a></code> for additional info</p></li>
<li><p><code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot()</a></code> generics for classes
<li><p><code>ggplot()</code> generics for classes
<code>&lt;mic&gt;</code> and <code>&lt;disk&gt;</code></p></li>
<li>
<p>Function <code><a href="../reference/mo_property.html">mo_is_yeast()</a></code>, which determines whether a
@ -697,7 +701,7 @@ printing)</li>
translated if the system language is German, Dutch or Spanish (see
<code>translate</code>)</li>
<li>Plotting is now possible with base R using <code><a href="../reference/plot.html">plot()</a></code> and
with ggplot2 using <code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot()</a></code> on any vector of MIC and disk
with ggplot2 using <code>ggplot()</code> on any vector of MIC and disk
diffusion values</li>
</ul></li>
<li>Updated SNOMED codes to US Edition of SNOMED CT from 1 September
@ -740,7 +744,7 @@ per hour)</li>
<li>Argument <code>ampc_cephalosporin_resistance</code> in
<code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> now also applies to value “I” (not only
“S”)</li>
<li>Functions <code><a href="https://docs.ropensci.org/skimr/reference/print.html" class="external-link">print()</a></code> and <code><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary()</a></code> on a
<li>Functions <code><a href="https://rdrr.io/r/base/print.html" class="external-link">print()</a></code> and <code><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary()</a></code> on a
Principal Components Analysis object (<code><a href="../reference/pca.html">pca()</a></code>) now print
additional group info if the original data was grouped using
<code><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">dplyr::group_by()</a></code>
@ -1266,10 +1270,10 @@ versions of R since R-3.0.0 (April 2013). Our package is being used in
settings where the resources are very limited. Fewer dependencies on
newer software is helpful for such settings.</p>
<p>Negative effects of this change are:</p>
<ul><li>Function <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq()</a></code> that was borrowed from the
<ul><li>Function <code>freq()</code> that was borrowed from the
<code>cleaner</code> package was removed. Use
<code><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">cleaner::freq()</a></code>, or run <code><a href="https://github.com/msberends/cleaner" class="external-link">library("cleaner")</a></code>
before you use <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq()</a></code>.</li>
before you use <code>freq()</code>.</li>
<li><del>Printing values of class <code>mo</code> or <code>rsi</code> in
a tibble will no longer be in colour and printing <code>rsi</code> in a
tibble will show the class <code>&lt;ord&gt;</code>, not
@ -1698,9 +1702,9 @@ data integrity, this means that invalid assignments will now result in
could never be understood by e.g. <code><a href="../reference/mo_property.html">mo_name()</a></code>, although the
class would suggest a valid microbial code.</p>
</li>
<li><p>Function <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq()</a></code> has moved to a new package, <a href="https://github.com/msberends/clean" class="external-link"><code>clean</code></a> (<a href="https://cran.r-project.org/package=clean" class="external-link">CRAN link</a>), since
<li><p>Function <code>freq()</code> has moved to a new package, <a href="https://github.com/msberends/clean" class="external-link"><code>clean</code></a> (<a href="https://cran.r-project.org/package=clean" class="external-link">CRAN link</a>), since
creating frequency tables actually does not fit the scope of this
package. The <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq()</a></code> function still works, since it is
package. The <code>freq()</code> function still works, since it is
re-exported from the <code>clean</code> package (which will be installed
automatically upon updating this <code>AMR</code> package).</p></li>
<li><p>Renamed data set <code>septic_patients</code> to
@ -2072,7 +2076,7 @@ since it uses <code><a href="../reference/count.html">count_df()</a></code> inte
<code>guess_atc()</code>, <code>EUCAST_rules()</code>,
<code>interpretive_reading()</code>, <code><a href="../reference/as.rsi.html">rsi()</a></code>
</li>
<li>Frequency tables (<code><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq()</a></code>):
<li>Frequency tables (<code>freq()</code>):
<ul><li><p>speed improvement for microbial IDs</p></li>
<li><p>fixed factor level names for R Markdown</p></li>
<li><p>when all values are unique it now shows a message instead of a
@ -2082,12 +2086,12 @@ warning</p></li>
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">septic_patients</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://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="va">age</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="fu">freq</span><span class="op">(</span><span class="va">age</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="fu"><a href="https://rdrr.io/r/graphics/boxplot.html" class="external-link">boxplot</a></span><span class="op">(</span><span class="op">)</span>
<span class="co"># grouped boxplots:</span>
<span class="va">septic_patients</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/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">hospital_id</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="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="va">age</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="fu">freq</span><span class="op">(</span><span class="va">age</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="fu"><a href="https://rdrr.io/r/graphics/boxplot.html" class="external-link">boxplot</a></span><span class="op">(</span><span class="op">)</span></code></pre></div>
</li>
</ul></li>
@ -2099,7 +2103,7 @@ be viewed here</a>
</li>
<li>Changed default settings for <code><a href="../reference/age_groups.html">age_groups()</a></code>, to let
groups of fives and tens end with 100+ instead of 120+</li>
<li>Fix for <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq()</a></code> for when all values are
<li>Fix for <code>freq()</code> for when all values are
<code>NA</code>
</li>
<li>Fix for <code><a href="../reference/first_isolate.html">first_isolate()</a></code> for when dates are missing</li>
@ -2435,7 +2439,7 @@ unique count, e.g. using <code>summary(mo)</code>
return <code>S</code>
</li>
</ul></li>
<li>Frequency tables (<code><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq()</a></code> function):
<li>Frequency tables (<code>freq()</code> function):
<ul><li>
<p>Support for tidyverse quasiquotation! Now you can create
frequency tables of function outcomes:</p>
@ -2445,15 +2449,15 @@ frequency tables of function outcomes:</p>
<span class="co"># OLD WAY</span>
<span class="va">septic_patients</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/mutate.html" class="external-link">mutate</a></span><span class="op">(</span>genus <span class="op">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="va">mo</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 class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="va">genus</span><span class="op">)</span>
<span class="fu">freq</span><span class="op">(</span><span class="va">genus</span><span class="op">)</span>
<span class="co"># NEW WAY</span>
<span class="va">septic_patients</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://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span><span class="op">)</span>
<span class="fu">freq</span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span><span class="op">)</span>
<span class="co"># Even supports grouping variables:</span>
<span class="va">septic_patients</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/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">gender</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="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<span class="fu">freq</span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span><span class="op">)</span></code></pre></div>
</li>
<li><p>Header info is now available as a list, with the
<code>header</code> function</p></li>
@ -2580,21 +2584,21 @@ total available isolate is below argument <code>minimum</code></p></li>
<code>as.mic</code>, <code>as.atc</code> and <code>freq</code> will not
set package name as attribute anymore</p></li>
<li>
<p>Frequency tables - <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq()</a></code>:</p>
<p>Frequency tables - <code>freq()</code>:</p>
<ul><li>
<p>Support for grouping variables, test with:</p>
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">septic_patients</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/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">hospital_id</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="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="va">gender</span><span class="op">)</span></code></pre></div>
<span class="fu">freq</span><span class="op">(</span><span class="va">gender</span><span class="op">)</span></code></pre></div>
</li>
<li>
<p>Support for (un)selecting columns:</p>
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">septic_patients</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://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="va">hospital_id</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="fu">freq</span><span class="op">(</span><span class="va">hospital_id</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="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="op">-</span><span class="va">count</span>, <span class="op">-</span><span class="va">cum_count</span><span class="op">)</span> <span class="co"># only get item, percent, cum_percent</span></code></pre></div>
</li>
<li><p>Check for <code><a href="https://hms.tidyverse.org/reference/Deprecated.html" class="external-link">hms::is.hms</a></code></p></li>
@ -2623,7 +2627,7 @@ to comply with CRAN policy to only allow ASCII characters</p></li>
<li><p>Fix for <code>eucast_rules</code> where some Streptococci would
become ceftazidime R in EUCAST rule 4.5</p></li>
<li><p>Support for named vectors of class <code>mo</code>, useful for
<code><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">top_freq()</a></code></p></li>
<code>top_freq()</code></p></li>
<li><p><code>ggplot_rsi</code> and <code>scale_y_percent</code> have
<code>breaks</code> argument</p></li>
<li>
@ -2848,13 +2852,13 @@ tables</p></li>
<div class="sourceCode" id="cb52"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">my_matrix</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/with.html" class="external-link">with</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="fu"><a href="https://rdrr.io/r/base/matrix.html" class="external-link">matrix</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="va">age</span>, <span class="va">gender</span><span class="op">)</span>, ncol <span class="op">=</span> <span class="fl">2</span><span class="op">)</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="va">my_matrix</span><span class="op">)</span></code></pre></div>
<span class="fu">freq</span><span class="op">(</span><span class="va">my_matrix</span><span class="op">)</span></code></pre></div>
<p>For lists, subsetting is possible:</p>
<div class="sourceCode" id="cb53"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">my_list</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span>age <span class="op">=</span> <span class="va">septic_patients</span><span class="op">$</span><span class="va">age</span>, gender <span class="op">=</span> <span class="va">septic_patients</span><span class="op">$</span><span class="va">gender</span><span class="op">)</span>
<span class="va">my_list</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://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="va">age</span><span class="op">)</span>
<span class="va">my_list</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://rdrr.io/pkg/cleaner/man/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="va">gender</span><span class="op">)</span></code></pre></div>
<span class="va">my_list</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu">freq</span><span class="op">(</span><span class="va">age</span><span class="op">)</span>
<span class="va">my_list</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu">freq</span><span class="op">(</span><span class="va">gender</span><span class="op">)</span></code></pre></div>
</li>
</ul></div>
<div class="section level5">

View File

@ -17,7 +17,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.1</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.8.0.9010</span>
</span>
</div>

View File

@ -201,6 +201,7 @@ expect_equal(as.character(as.mo("g aponina")), "B_GMPHS_APNN")
expect_equal(suppressMessages(as.character(as.mo("Escherichia blattae"))), "B_SHMWL_BLTT")
print(mo_renamed())
expect_equal(suppressMessages(as.character(as.mo(c("E. coli", "Chlamydo psittaci")))), c("B_ESCHR_COLI", "B_CHLMY_PSTT"))
expect_equal(suppressMessages(mo_name("eubcom")), "Clostridium combesii")
# check uncertain names
expect_equal(suppressMessages(as.character(as.mo("staaur extratest", allow_uncertain = TRUE))), "B_STPHY_AURS")