(v1.7.1.9077) skimr support only for newer R versions

This commit is contained in:
dr. M.S. (Matthijs) Berends 2021-12-23 13:38:25 +01:00
parent ed22b83c28
commit 75dac113b6
9 changed files with 45 additions and 27 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 1.7.1.9075
Date: 2021-12-14
Version: 1.7.1.9077
Date: 2021-12-23
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.7.1.9075
## <small>Last updated: 14 December 2021</small>
# `AMR` 1.7.1.9077
## <small>Last updated: 23 December 2021</small>
All functions in this package are now all 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 from now on.

16
R/ab.R
View File

@ -133,8 +133,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
note_if_more_than_one_found <- function(found, index, from_text) {
if (initial_search == TRUE & isTRUE(length(from_text) > 1)) {
abnames <- ab_name(from_text, tolower = TRUE, initial_search = FALSE)
if (ab_name(found[1L], language = NULL) %like% "clavulanic acid") {
abnames <- abnames[!abnames == "clavulanic acid"]
if (ab_name(found[1L], language = NULL) %like% "(clavulanic acid|avibactam)") {
abnames <- abnames[!abnames %in% c("clavulanic acid", "avibactam")]
}
if (length(abnames) > 1) {
message_("More than one result was found for item ", index, ": ",
@ -222,6 +222,16 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
next
}
# length of input is quite long, and Levenshtein distance is only max 2
if (nchar(x[i]) >= 10) {
levenshtein <- as.double(utils::adist(x[i], AB_lookup$generalised_name))
if (any(levenshtein <= 2)) {
found <- AB_lookup$ab[which(levenshtein <= 2)]
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
next
}
}
# allow characters that resemble others, but only continue when having more than 3 characters
if (nchar(x[i]) <= 3) {
x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1])
@ -238,7 +248,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_spelling <- gsub("E+", "E+", x_spelling, perl = TRUE)
x_spelling <- gsub("O+", "O+", x_spelling, perl = TRUE)
# allow any ending of -in/-ine and -im/-ime
x_spelling <- gsub("(\\[IY\\]\\+(N|M)|\\[IY\\]\\+(N|M)E\\+)$", "[IY]+(N|M)E*", x_spelling, perl = TRUE)
x_spelling <- gsub("(\\[IY\\]\\+(N|M)|\\[IY\\]\\+(N|M)E\\+?)$", "[IY]+(N|M)E*", x_spelling, perl = TRUE)
# allow any ending of -ol/-ole
x_spelling <- gsub("(O\\+L|O\\+LE\\+)$", "O+LE*", x_spelling, perl = TRUE)
# allow any ending of -on/-one

10
R/zzz.R
View File

@ -57,10 +57,12 @@ if (utf8_supported && !is_latex) {
s3_register("cleaner::freq", "mo")
s3_register("cleaner::freq", "rsi")
# Support for skim() from the skimr package
s3_register("skimr::get_skimmers", "mo")
s3_register("skimr::get_skimmers", "rsi")
s3_register("skimr::get_skimmers", "mic")
s3_register("skimr::get_skimmers", "disk")
if (pkg_is_available("skimr", also_load = FALSE, min_version = "2.0.0")) {
s3_register("skimr::get_skimmers", "mo")
s3_register("skimr::get_skimmers", "rsi")
s3_register("skimr::get_skimmers", "mic")
s3_register("skimr::get_skimmers", "disk")
}
# Support for autoplot() from the ggplot2 package
s3_register("ggplot2::autoplot", "rsi")
s3_register("ggplot2::autoplot", "mic")

Binary file not shown.

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.7.1.9075</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.7.1.9077</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 December 2021</h4>
<h4 data-toc-skip class="date">23 December 2021</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>
@ -495,7 +495,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
</h2>
<p>A data set with 464 rows and 14 columns, containing the following column names:<br><em>ab</em>, <em>cid</em>, <em>name</em>, <em>group</em>, <em>atc</em>, <em>atc_group1</em>, <em>atc_group2</em>, <em>abbreviations</em>, <em>synonyms</em>, <em>oral_ddd</em>, <em>oral_units</em>, <em>iv_ddd</em>, <em>iv_units</em> and <em>loinc</em>.</p>
<p>This data set is in R available as <code>antibiotics</code>, after you load the <code>AMR</code> package.</p>
<p>It was last updated on 13 December 2021 09:13:56 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
<p>It was last updated on 14 December 2021 21:59:33 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
<p><strong>Direct download links:</strong></p>
<ul>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/../data-raw/antibiotics.rds" class="external-link">R file</a> (33 kB)<br>
@ -790,7 +790,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
</h2>
<p>A data set with 134,956 rows and 2 columns, containing the following column names:<br><em>mo</em> and <em>ab</em>.</p>
<p>This data set is in R available as <code>intrinsic_resistant</code>, after you load the <code>AMR</code> package.</p>
<p>It was last updated on 14 December 2021 17:16:54 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/intrinsic_resistant.html">here</a>.</p>
<p>It was last updated on 14 December 2021 21:59:33 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/intrinsic_resistant.html">here</a>.</p>
<p><strong>Direct download links:</strong></p>
<ul>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/../data-raw/intrinsic_resistant.rds" class="external-link">R file</a> (78 kB)<br>
@ -1057,7 +1057,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
</h2>
<p>A data set with 20,318 rows and 11 columns, containing the following column names:<br><em>guideline</em>, <em>method</em>, <em>site</em>, <em>mo</em>, <em>rank_index</em>, <em>ab</em>, <em>ref_tbl</em>, <em>disk_dose</em>, <em>breakpoint_S</em>, <em>breakpoint_R</em> and <em>uti</em>.</p>
<p>This data set is in R available as <code>rsi_translation</code>, after you load the <code>AMR</code> package.</p>
<p>It was last updated on 14 December 2021 21:17:09 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/rsi_translation.html">here</a>.</p>
<p>It was last updated on 14 December 2021 21:59:33 UTC. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/rsi_translation.html">here</a>.</p>
<p><strong>Direct download links:</strong></p>
<ul>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/../data-raw/rsi_translation.rds" class="external-link">R file</a> (39 kB)<br>

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.7.1.9075</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.7.1.9077</span>
</span>
</div>
@ -157,13 +157,13 @@
</div>
<div class="section level2">
<h2 class="page-header" data-toc-text="1.7.1.9075" id="amr-1719075">
<code>AMR</code> 1.7.1.9075<a class="anchor" aria-label="anchor" href="#amr-1719075"></a></h2>
<h2 class="page-header" data-toc-text="1.7.1.9077" id="amr-1719077">
<code>AMR</code> 1.7.1.9077<a class="anchor" aria-label="anchor" href="#amr-1719077"></a></h2>
<div class="section level3">
<h3 id="last-updated-december-1-7-1-9075"><small>Last updated: 14 December 2021</small><a class="anchor" aria-label="anchor" href="#last-updated-december-1-7-1-9075"></a></h3>
<h3 id="last-updated-december-1-7-1-9077"><small>Last updated: 23 December 2021</small><a class="anchor" aria-label="anchor" href="#last-updated-december-1-7-1-9077"></a></h3>
<p>All functions in this package are now all 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 from now on.</p>
<div class="section level4">
<h4 id="breaking-changes-1-7-1-9075">Breaking changes<a class="anchor" aria-label="anchor" href="#breaking-changes-1-7-1-9075"></a></h4>
<h4 id="breaking-changes-1-7-1-9077">Breaking changes<a class="anchor" aria-label="anchor" href="#breaking-changes-1-7-1-9077"></a></h4>
<ul><li>Removed <code>p_symbol()</code> and all <code>filter_*()</code> functions (except for <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>), which were all deprecated in a previous package version</li>
<li>Removed the <code>key_antibiotics()</code> and <code>key_antibiotics_equal()</code> functions, which were deprecated and superseded by <code><a href="../reference/key_antimicrobials.html">key_antimicrobials()</a></code> and <code><a href="../reference/key_antimicrobials.html">antimicrobials_equal()</a></code>
</li>
@ -171,7 +171,7 @@
<li>Renamed function <code>get_locale()</code> to <code><a href="../reference/translate.html">get_AMR_locale()</a></code> to prevent conflicts with other packages</li>
</ul></div>
<div class="section level4">
<h4 id="new-1-7-1-9075">New<a class="anchor" aria-label="anchor" href="#new-1-7-1-9075"></a></h4>
<h4 id="new-1-7-1-9077">New<a class="anchor" aria-label="anchor" href="#new-1-7-1-9077"></a></h4>
<ul><li><p>Support for the CLSI 2021 guideline for interpreting MIC/disk diffusion values, which are incorporated in the <code>rsi_translation</code> data set. This data set now more strictly follows the WHONET software as well.</p></li>
<li><p>Support for EUCAST Intrinsic Resistance and Unusual Phenotypes v3.3 (October 2021). This is now the default EUCAST guideline in the package (all older guidelines are still available) for <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>, <code><a href="../reference/mo_property.html">mo_is_intrinsic_resistant()</a></code> and <code><a href="../reference/mdro.html">mdro()</a></code>. The <code>intrinsic_resistant</code> data set was also updated accordingly.</p></li>
<li><p>Support for all antimicrobial drug (group) names and colloquial microorganism names in Danish, Dutch, English, French, German, Italian, Portuguese, Russian, Spanish and Swedish</p></li>
@ -186,7 +186,7 @@
<li><p>Function <code><a href="../reference/ab_property.html">ab_ddd_units()</a></code> to get units of DDDs (daily defined doses), deprecating the use of <code>ab_ddd(..., units = TRUE)</code> to be more consistent in data types of function output</p></li>
</ul></div>
<div class="section level4">
<h4 id="changed-1-7-1-9075">Changed<a class="anchor" aria-label="anchor" href="#changed-1-7-1-9075"></a></h4>
<h4 id="changed-1-7-1-9077">Changed<a class="anchor" aria-label="anchor" href="#changed-1-7-1-9077"></a></h4>
<ul><li>Updated the bacterial taxonomy to 5 October 2021 (according to <a href="https://lpsn.dsmz.de" class="external-link">LPSN</a>), including all 11 new staphylococcal species named since 1 January last year</li>
<li>The <code>antibiotics</code> data set now contains <strong>all ATC codes</strong> that are available through the <a href="https://www.whocc.no" class="external-link">WHOCC website</a>, regardless of drugs being present in more than one ATC group. This means that:
<ul><li>Some drugs now contain multiple ATC codes (e.g., metronidazole contains 5)</li>
@ -258,7 +258,7 @@
<code><a href="../reference/get_episode.html">get_episode()</a></code> and <code><a href="../reference/get_episode.html">is_new_episode()</a></code> can now cope with <code>NA</code>s</li>
</ul></div>
<div class="section level4">
<h4 id="other-1-7-1-9075">Other<a class="anchor" aria-label="anchor" href="#other-1-7-1-9075"></a></h4>
<h4 id="other-1-7-1-9077">Other<a class="anchor" aria-label="anchor" href="#other-1-7-1-9077"></a></h4>
<ul><li>This package is now being maintained by two epidemiologists and a data scientist from two different non-profit healthcare organisations.</li>
</ul></div>
</div>

View File

@ -61,6 +61,9 @@ expect_equal(as.character(as.ab(c("mreopenem", "co-maoxiclav"))),
expect_message(as.ab("cipro mero"))
# based on Levenshtein distance
expect_identical(ab_name("ceftazidim/avibactam", language = NULL), "Ceftazidime/avibactam")
# assigning and subsetting
x <- antibiotics$ab
expect_inherits(x[1], "ab")

View File

@ -52,9 +52,6 @@ import_functions <- c(
call_functions <- c(
# cleaner
"freq.default" = "cleaner",
# skimr
"inline_hist" = "skimr",
"sfl" = "skimr",
# readxl
"read_excel" = "readxl",
# ggplot2
@ -85,6 +82,12 @@ call_functions <- c(
"xlab" = "ggplot2",
"ylab" = "ggplot2"
)
if (pkg_is_available("skimr", also_load = FALSE, min_version = "2.0.0")) {
call_functions <- c(call_functions,
# skimr
"inline_hist" = "skimr",
"sfl" = "skimr")
}
extended_functions <- c(
"freq" = "cleaner",