mirror of
https://github.com/msberends/AMR.git
synced 2025-07-15 18:43:12 +02:00
(v1.3.0.9035) mdro() for EUCAST 3.2, examples cleanup
This commit is contained in:
@ -50,7 +50,7 @@
|
||||
|
||||
<meta property="og:title" content="Key antibiotics for first weighted isolates — key_antibiotics" />
|
||||
<meta property="og:description" content="These function can be used to determine first isolates (see first_isolate()). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates will then be called first weighted isolates." />
|
||||
<meta property="og:image" content="https://msberends.github.io/AMR/logo.svg" />
|
||||
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
|
||||
|
||||
|
||||
|
||||
@ -82,7 +82,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="Latest development version">1.3.0.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -395,32 +395,35 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
|
||||
<pre class="examples"><span class='co'># `example_isolates` is a dataset available in the AMR package.</span>
|
||||
<span class='co'># See ?example_isolates.</span>
|
||||
|
||||
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
|
||||
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
|
||||
<span class='co'># set key antibiotics to a new variable</span>
|
||||
<span class='kw'>my_patients</span> <span class='op'><-</span> <span class='kw'>example_isolates</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(keyab = <span class='fu'>key_antibiotics</span>(<span class='kw'>.</span>)) <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(
|
||||
<span class='co'># now calculate first isolates</span>
|
||||
first_regular = <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='kw'>.</span>, col_keyantibiotics = <span class='fl'>FALSE</span>),
|
||||
<span class='co'># and first WEIGHTED isolates</span>
|
||||
first_weighted = <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='kw'>.</span>, col_keyantibiotics = <span class='st'>"keyab"</span>)
|
||||
)
|
||||
|
||||
<span class='co'># Check the difference, in this data set it results in 7% more isolates:</span>
|
||||
<span class='fu'><a href='https://rdrr.io/r/base/sum.html'>sum</a></span>(<span class='kw'>my_patients</span><span class='op'>$</span><span class='kw'>first_regular</span>, na.rm = <span class='fl'>TRUE</span>)
|
||||
<span class='fu'><a href='https://rdrr.io/r/base/sum.html'>sum</a></span>(<span class='kw'>my_patients</span><span class='op'>$</span><span class='kw'>first_weighted</span>, na.rm = <span class='fl'>TRUE</span>)
|
||||
}
|
||||
|
||||
<span class='co'># output of the `key_antibiotics` function could be like this:</span>
|
||||
<span class='kw'>strainA</span> <span class='op'><-</span> <span class='st'>"SSSRR.S.R..S"</span>
|
||||
<span class='kw'>strainB</span> <span class='op'><-</span> <span class='st'>"SSSIRSSSRSSS"</span>
|
||||
|
||||
<span class='co'># can those strings can be compared with:</span>
|
||||
<span class='fu'>key_antibiotics_equal</span>(<span class='kw'>strainA</span>, <span class='kw'>strainB</span>)
|
||||
<span class='co'># TRUE, because I is ignored (as well as missing values)</span>
|
||||
|
||||
<span class='fu'>key_antibiotics_equal</span>(<span class='kw'>strainA</span>, <span class='kw'>strainB</span>, ignore_I = <span class='fl'>FALSE</span>)
|
||||
<span class='co'># FALSE, because I is not ignored and so the 4th value differs</span></pre>
|
||||
<span class='co'># FALSE, because I is not ignored and so the 4th value differs</span>
|
||||
|
||||
<span class='co'># \donttest{</span>
|
||||
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
|
||||
<span class='co'># set key antibiotics to a new variable</span>
|
||||
<span class='kw'>my_patients</span> <span class='op'><-</span> <span class='kw'>example_isolates</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(keyab = <span class='fu'>key_antibiotics</span>(<span class='kw'>.</span>)) <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(
|
||||
<span class='co'># now calculate first isolates</span>
|
||||
first_regular = <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='kw'>.</span>, col_keyantibiotics = <span class='fl'>FALSE</span>),
|
||||
<span class='co'># and first WEIGHTED isolates</span>
|
||||
first_weighted = <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='kw'>.</span>, col_keyantibiotics = <span class='st'>"keyab"</span>)
|
||||
)
|
||||
|
||||
<span class='co'># Check the difference, in this data set it results in 7% more isolates:</span>
|
||||
<span class='fu'><a href='https://rdrr.io/r/base/sum.html'>sum</a></span>(<span class='kw'>my_patients</span><span class='op'>$</span><span class='kw'>first_regular</span>, na.rm = <span class='fl'>TRUE</span>)
|
||||
<span class='fu'><a href='https://rdrr.io/r/base/sum.html'>sum</a></span>(<span class='kw'>my_patients</span><span class='op'>$</span><span class='kw'>first_weighted</span>, na.rm = <span class='fl'>TRUE</span>)
|
||||
}
|
||||
<span class='co'># }</span>
|
||||
</pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
|
||||
<nav id="toc" data-toggle="toc" class="sticky-top">
|
||||
|
Reference in New Issue
Block a user