diff --git a/DESCRIPTION b/DESCRIPTION index f74971b2..1af369ff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 0.7.1.9022 +Version: 0.7.1.9023 Date: 2019-08-04 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index c012573a..4776489b 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,7 @@ -# AMR 0.7.1.9022 +# AMR 0.7.1.9023 ### Breaking -* Function `freq()` has moved to a new package, [`clean`](https://github.com/msberends/clean) ([CRAN link](https://cran.r-project.org/package=clean)). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. We decided to create a new package for data cleaning and checking and it perfectly fits the `freq()` function. The [`clean`](https://github.com/msberends/clean) package is available on CRAN and will be installed automatically when updating the `AMR` package, that now imports it. In a later stage, the `skewness()` and `kurtosis()` functions will be moved to the `clean` package too. +* Function `freq()` has moved to a new package, [`clean`](https://github.com/msberends/clean) ([CRAN link](https://cran.r-project.org/package=clean)). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. Therefore, a new package was created for data cleaning and checking and it perfectly fits the `freq()` function. The [`clean`](https://github.com/msberends/clean) package is available on CRAN and will be installed automatically when updating the `AMR` package, that now imports it. In a later stage, the `skewness()` and `kurtosis()` functions will be moved to the `clean` package too. ### New * Additional way to calculate co-resistance, i.e. when using multiple antibiotics as input for `portion_*` functions or `count_*` functions. This can be used to determine the empiric susceptibily of a combination therapy. A new parameter `only_all_tested` (**which defaults to `FALSE`**) replaces the old `also_single_tested` and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the `portion` and `count` help pages), where the %SI is being determined: diff --git a/R/misc.R b/R/misc.R index 6ab8c09e..7040eb00 100755 --- a/R/misc.R +++ b/R/misc.R @@ -71,18 +71,20 @@ size_humanreadable <- function(bytes, decimals = 1) { out } -percent_scales <- scales::percent +percent_clean <- clean:::percent # No export, no Rd -# based on scales::percent -percent <- function(x, round = 1, force_zero = FALSE, decimal.mark = getOption("OutDec"), ...) { - x <- percent_scales(x = as.double(x), - accuracy = 1 / 10 ^ round, - decimal.mark = decimal.mark, - ...) - if (force_zero == FALSE) { - x <- gsub("([.]%|%%)", "%", paste0(gsub("0+%$", "", x), "%")) +percent <- function(x, round = 1, force_zero = FALSE, decimal.mark = getOption("OutDec"), big.mark = ",", ...) { + if (decimal.mark == big.mark) { + if (decimal.mark == ",") { + big.mark <- "." + } else if (decimal.mark == ".") { + big.mark <- "," + } else { + big.mark <- " " + } } - x + x <- percent_clean(x = x, round = round, force_zero = force_zero, + decimal.mark = decimal.mark, big.mark = big.mark, ...) } #' @importFrom crayon blue bold red diff --git a/R/mo.R b/R/mo.R index bf14e7af..47cd6664 100755 --- a/R/mo.R +++ b/R/mo.R @@ -1238,10 +1238,10 @@ exec_as.mo <- function(x, if (n_distinct(failures) > 1) { plural <- c("values", "them", "were") } - total_failures <- length(x_input[x_input %in% failures & !x_input %in% c(NA, NULL, NaN)]) + total_failures <- length(x_input[as.character(x_input) %in% as.character(failures) & !x_input %in% c(NA, NULL, NaN)]) total_n <- length(x_input[!x_input %in% c(NA, NULL, NaN)]) msg <- paste0(nr2char(n_distinct(failures)), " unique ", plural[1], - " (^= ", percent(total_failures / total_n, round = 1, force_zero = TRUE), + " (covering ", percent(total_failures / total_n, round = 1, force_zero = TRUE), ") could not be coerced and ", plural[3], " considered 'unknown'") if (n_distinct(failures) <= 10) { msg <- paste0(msg, ": ", paste('"', unique(failures), '"', sep = "", collapse = ', ')) diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 0be3b28d..6b0af1f4 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@
diff --git a/docs/articles/index.html b/docs/articles/index.html index 4d62047d..c48fa4b1 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -78,7 +78,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 00fdb2df..5a4b4dc2 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -78,7 +78,7 @@ diff --git a/docs/index.html b/docs/index.html index 82f9f921..09fce559 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ @@ -197,14 +197,14 @@This package is ready-to-use for a professional environment by specialists in the following fields:
@@ -307,7 +307,7 @@It cleanses existing data by providing new classes for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use intelligent rules to guess results that you would expect:
as.mo()
to get a microbial ID. The IDs are human readable for the trained eye - the ID of Klebsiella pneumoniae is “B_KLBSL_PNE” (B stands for Bacteria) and the ID of S. aureus is “B_STPHY_AUR”. The function takes almost any text as input that looks like the name or code of a microorganism like “E. coli”, “esco” or “esccol” and tries to find expected results using intelligent rules combined with the included Catalogue of Life data set. It only takes milliseconds to find results, please see our benchmarks. Moreover, it can group Staphylococci into coagulase negative and positive (CoNS and CoPS, see source) and can categorise Streptococci into Lancefield groups (like beta-haemolytic Streptococcus Group B, source).as.ab()
to get an antibiotic ID. Like microbial IDs, these IDs are also human readable based on those used by EARS-Net. For example, the ID of amoxicillin is AMX
and the ID of gentamicin is GEN
. The as.ab()
function also uses intelligent rules to find results like accepting misspelling, trade names and abbrevations used in many laboratory systems. For instance, the values “Furabid”, “Furadantin”, “nitro” all return the ID of Nitrofurantoine. To accomplish this, the package contains a database with most LIS codes, official names, trade names, DDDs and categories of antibiotics. The function as.atc()
will return the ATC code of an antibiotic as defined by the WHO.as.ab()
to get an antibiotic ID. Like microbial IDs, these IDs are also human readable based on those used by EARS-Net. For example, the ID of amoxicillin is AMX
and the ID of gentamicin is GEN
. The as.ab()
function also uses intelligent rules to find results like accepting misspelling, trade names and abbrevations used in many laboratory systems. For instance, the values “Furabid”, “Furadantin”, “nitro” all return the ID of Nitrofurantoine. To accomplish this, the package contains a database with most LIS codes, official names, trade names, ATC codes, defined daily doses (DDD) and drug categories of antibiotics.as.rsi()
to get antibiotic interpretations based on raw MIC values (in mg/L) or disk diffusion values (in mm), or transform existing values to valid antimicrobial results. It produces just S, I or R based on your input and warns about invalid values. Even values like “<=0.002; S” (combined MIC/RSI) will result in “S”.as.mic()
to cleanse your MIC values. It produces a so-called factor (called ordinal in SPSS) with valid MIC values as levels. A value like “<=0.002; S” (combined MIC/RSI) will result in “<=0.002”.mdro()
(abbreviation of Multi Drug Resistant Organisms) to check your isolates for exceptional resistance with country-specific guidelines or EUCAST rules. Currently, national guidelines for Germany and the Netherlands are supported.microorganisms
contains the complete taxonomic tree of ~65,000 microorganisms. Furthermore, some colloquial names and all Gram stains are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like mo_genus()
, mo_family()
, mo_gramstain()
or even mo_phylum()
. As they use as.mo()
internally, they also use the same intelligent rules for determination. For example, mo_genus("MRSA")
and mo_genus("S. aureus")
will both return "Staphylococcus"
. They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data.antibiotics
contains ~450 antimicrobial drugs with their EARS-Net code, ATC code, PubChem compound ID, official name, common LIS codes and DDDs of both oral and parenteral administration. It also contains all (thousands of) trade names found in PubChem. Use functions like ab_name()
, ab_group()
and ab_tradenames()
to look up values. The ab_*
functions use as.ab()
internally so they support the same intelligent rules to guess the most probable result. For example, ab_name("Fluclox")
, ab_name("Floxapen")
and ab_name("J01CF05")
will all return "Flucloxacillin"
. These functions can again be used to add new variables to your data.antibiotics
contains ~450 antimicrobial drugs with their EARS-Net code, ATC code, PubChem compound ID, official name, common LIS codes and DDDs of both oral and parenteral administration. It also contains all (thousands of) trade names found in PubChem. The function ab_atc()
will return the ATC code of an antibiotic as defined by the WHO. Use functions like ab_name()
, ab_group()
and ab_tradenames()
to look up values. The ab_*
functions use as.ab()
internally so they support the same intelligent rules to guess the most probable result. For example, ab_name("Fluclox")
, ab_name("Floxapen")
and ab_name("J01CF05")
will all return "Flucloxacillin"
. These functions can again be used to add new variables to your data.freq()
has moved to a new package, clean
(CRAN link). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. We decided to create a new package for data cleaning and checking and it perfectly fits the freq()
function. The clean
package is available on CRAN and will be installed automatically when updating the AMR
package, that now imports it. In a later stage, the skewness()
and kurtosis()
functions will be moved to the clean
package too.freq()
has moved to a new package, clean
(CRAN link). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. Therefore, a new package was created for data cleaning and checking and it perfectly fits the freq()
function. The clean
package is available on CRAN and will be installed automatically when updating the AMR
package, that now imports it. In a later stage, the skewness()
and kurtosis()
functions will be moved to the clean
package too.as.mo(..., allow_uncertain = 3)
Contents