diff --git a/DESCRIPTION b/DESCRIPTION index 80a90303..3c99e282 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.7.1.9056 -Date: 2021-11-29 +Version: 1.7.1.9057 +Date: 2021-12-02 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 20a10107..c4c3ed59 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# `AMR` 1.7.1.9056 -## Last updated: 29 November 2021 +# `AMR` 1.7.1.9057 +## Last updated: 2 December 2021 ### Breaking changes * Removed `p_symbol()` and all `filter_*()` functions (except for `filter_first_isolate()`), which were all deprecated in a previous package version @@ -56,6 +56,7 @@ * The `mdro()` function now returns `NA` for all rows that have no test results * The `species_id` column in the `microorganisms` data set now only contains LPSN record numbers. For this reason, this column is now numeric instead of a character, and `mo_url()` has been updated to reflect this change. * Fixed a small bug in the functions `get_episode()` and `is_new_episode()` +* `get_episode()` and `is_new_episode()` can now cope with `NA`s ### Other * This package is now being maintained by two epidemiologists and a data scientist from two different non-profit healthcare organisations. 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. diff --git a/R/episode.R b/R/episode.R index 90bd8cf3..bc1462eb 100644 --- a/R/episode.R +++ b/R/episode.R @@ -105,7 +105,7 @@ #' } #' } get_episode <- function(x, episode_days, ...) { - meet_criteria(x, allow_class = c("Date", "POSIXt")) + meet_criteria(x, allow_class = c("Date", "POSIXt"), allow_NA = TRUE) meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE) exec_episode(x = x, @@ -117,7 +117,7 @@ get_episode <- function(x, episode_days, ...) { #' @rdname get_episode #' @export is_new_episode <- function(x, episode_days, ...) { - meet_criteria(x, allow_class = c("Date", "POSIXt")) + meet_criteria(x, allow_class = c("Date", "POSIXt"), allow_NA = TRUE) meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = FALSE) exec_episode(x = x, @@ -131,13 +131,13 @@ exec_episode <- function(x, type, episode_days, ...) { # since x is now in seconds, get seconds from episode_days as well episode_seconds <- episode_days * 60 * 60 * 24 - if (length(x) == 1) { + if (length(x) == 1) { # this will also match 1 NA, which is fine if (type == "logical") { return(TRUE) } else if (type == "sequential") { return(1) } - } else if (length(x) == 2) { + } else if (length(x) == 2 && !all(is.na(x))) { if (max(x) - min(x) >= episode_seconds) { if (type == "logical") { return(c(TRUE, TRUE)) @@ -182,5 +182,7 @@ exec_episode <- function(x, type, episode_days, ...) { } ord <- order(x) - run_episodes(x[ord], episode_seconds)[order(ord)] + out <- run_episodes(x[ord], episode_seconds)[order(ord)] + out[is.na(x) & ord != 1] <- NA # every NA but the first must remain NA + out } diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index de431cce..a9e8a857 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 60119012..feed0d58 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -30,6 +30,8 @@
+ +vignettes/datasets.Rmd
+ Source: vignettes/datasets.Rmd
datasets.Rmd
If you are reading this page from within R, please visit our website, which is automatically updated with every code change.
-A data set with 70,760 rows and 16 columns, containing the following column names:
mo, fullname, kingdom, phylum, class, order, family, genus, species, subspecies, rank, ref, species_id, source, prevalence and snomed.
This data set is in R available as microorganisms
, after you load the AMR
package.
It was last updated on 29 November 2021 10:22:24 UTC. Find more info about the structure of this data set here.
+It was last updated on 29 November 2021 11:38:23 UTC. Find more info about the structure of this data set here.
Direct download links:
NOTE: The exported files for SAS, SPSS and Stata do not contain SNOMED codes, as their file size would exceed 100 MB; the file size limit of GitHub. Advice? Use R instead.
-Our full taxonomy of microorganisms is based on the authoritative and comprehensive:
Included (sub)species per taxonomic kingdom: