diff --git a/DESCRIPTION b/DESCRIPTION index ad9c6049..042566db 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/NEWS.md b/NEWS.md index 18f36e42..02c8e64c 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# `AMR` 1.8.1 - +# `AMR` 1.8.0.9010 +## Last updated: 15 March 2022 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 diff --git a/R/mic.R b/R/mic.R index adf73c8d..431ff46b 100755 --- a/R/mic.R +++ b/R/mic.R @@ -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 diff --git a/R/mo.R b/R/mo.R index 62f291f3..dea905c9 100755 --- a/R/mo.R +++ b/R/mo.R @@ -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, diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 94158329..4deae43b 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/docs/404.html b/docs/404.html index 280769ef..3e4fea67 100644 --- a/docs/404.html +++ b/docs/404.html @@ -43,7 +43,7 @@
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index d3d3defe..358e2515 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -17,7 +17,7 @@ diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 92c297eb..bc954f2f 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -44,7 +44,7 @@ @@ -190,7 +190,7 @@vignettes/datasets.Rmd
datasets.Rmd
AMR
1.8.1AMR
1.8.0.9010All 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.
Fix for using as.rsi()
on values containing capped
values (such as >=
), sometimes leading to
NA
More informative warning messages
Added 192 as valid MIC
Updated MIC printing in tibbles
Increased speed for loading the package
as.ab()
and all ab_*()
functionsfortify()
extensions for plotting methodsfortify()
extensions for plotting methodsNA
values of the classes <mic>
,
<disk>
and <rsi>
are now exported
@@ -484,7 +488,7 @@ rewritten.filter_betalactams()
as additional
antbiotic column filter. The group of betalactams consists of all
carbapenems, cephalosporins and penicillins.
-ggplot()
method for
+ggplot()
method for
resistance_predict()
Support for custom MDRO guidelines, using the new
custom_mdro_guideline()
function, please see
mdro()
for additional info
ggplot()
generics for classes
+
ggplot()
generics for classes
<mic>
and <disk>
Function mo_is_yeast()
, which determines whether a
@@ -697,7 +701,7 @@ printing)
translate
)
plot()
and
-with ggplot2 using ggplot()
on any vector of MIC and disk
+with ggplot2 using ggplot()
on any vector of MIC and disk
diffusion valuesampc_cephalosporin_resistance
in
eucast_rules()
now also applies to value “I” (not only
“S”)print()
and summary()
on a
+print()
and summary()
on a
Principal Components Analysis object (pca()
) now print
additional group info if the original data was grouped using
dplyr::group_by()
@@ -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.
Negative effects of this change are:
-freq()
that was borrowed from the
+freq()
that was borrowed from the
cleaner
package was removed. Use
cleaner::freq()
, or run library("cleaner")
-before you use freq()
.freq()
.mo
or rsi
in
a tibble will no longer be in colour and printing rsi
in a
tibble will show the class <ord>
, not
@@ -1698,9 +1702,9 @@ data integrity, this means that invalid assignments will now result in
could never be understood by e.g. mo_name()
, although the
class would suggest a valid microbial code.
Function freq()
has moved to a new package, clean
(CRAN link), since
+
Function freq()
has moved to a new package, clean
(CRAN link), since
creating frequency tables actually does not fit the scope of this
-package. The freq()
function still works, since it is
+package. The freq()
function still works, since it is
re-exported from the clean
package (which will be installed
automatically upon updating this AMR
package).
Renamed data set septic_patients
to
@@ -2072,7 +2076,7 @@ since it uses count_df()
inte
guess_atc()
, EUCAST_rules()
,
interpretive_reading()
, rsi()
freq()
):
+freq()
):
speed improvement for microbial IDs
fixed factor level names for R Markdown
when all values are unique it now shows a message instead of a @@ -2082,12 +2086,12 @@ warning
age_groups()
, to let
groups of fives and tens end with 100+ instead of 120+freq()
for when all values are
+freq()
for when all values are
NA
first_isolate()
for when dates are missingsummary(mo)
return S
-freq()
function):
+freq()
function):
Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:
@@ -2445,15 +2449,15 @@ frequency tables of function outcomes: # OLD WAY septic_patients %>% mutate(genus = mo_genus(mo)) %>% - freq(genus) + freq(genus) # NEW WAY septic_patients %>% - freq(mo_genus(mo)) + freq(mo_genus(mo)) # Even supports grouping variables: septic_patients %>% group_by(gender) %>% - freq(mo_genus(mo)) + freq(mo_genus(mo))Header info is now available as a list, with the
header
function
minimum
as.mic
, as.atc
and freq
will not
set package name as attribute anymore
Frequency tables - freq()
:
Frequency tables - freq()
:
Support for grouping variables, test with:
+ freq(gender)Support for (un)selecting columns:
Check for hms::is.hms
Fix for eucast_rules
where some Streptococci would
become ceftazidime R in EUCAST rule 4.5
Support for named vectors of class mo
, useful for
-top_freq()
top_freq()
ggplot_rsi
and scale_y_percent
have
breaks
argument
For lists, subsetting is possible:
my_list = list(age = septic_patients$age, gender = septic_patients$gender)
-my_list %>% freq(age)
-my_list %>% freq(gender)