From ea4e5e5b8182b252697fbc58f98cc84698eec2d4 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Wed, 29 Jul 2020 13:48:50 +0200 Subject: [PATCH] (v1.3.0) v1.3.0 --- DESCRIPTION | 2 +- NEWS.md | 4 +- R/rsi.R | 68 ++++++++++++++--------------- docs/404.html | 2 +- docs/LICENSE-text.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 13 ++---- docs/pkgdown.yml | 2 +- docs/reference/as.rsi.html | 20 ++++----- docs/reference/index.html | 2 +- docs/reference/rsi_translation.html | 2 +- docs/survey.html | 2 +- man/as.rsi.Rd | 16 +++---- 15 files changed, 68 insertions(+), 73 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8b342075..4fb8a474 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.2.0.9040 +Version: 1.3.0 Date: 2020-07-29 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index b281a667..35b24613 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.2.0.9040 -## Last updated: 29 July 2020 +# AMR 1.3.0 + ### New * Function `ab_from_text()` to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses `as.ab()` internally diff --git a/R/rsi.R b/R/rsi.R index ee2eae43..447fc94f 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -143,6 +143,40 @@ as.rsi <- function(x, ...) { UseMethod("as.rsi") } +#' @rdname as.rsi +#' @export +is.rsi <- function(x) { + inherits(x, "rsi") +} + +#' @rdname as.rsi +#' @export +is.rsi.eligible <- function(x, threshold = 0.05) { + stop_if(NCOL(x) > 1, "`x` must be a one-dimensional vector.") + + if (any(c("logical", + "numeric", + "integer", + "mo", + "Date", + "POSIXct", + "rsi", + "raw", + "hms") + %in% class(x))) { + # no transformation needed + FALSE + } else { + x <- x[!is.na(x) & !is.null(x) & !identical(x, "")] + if (length(x) == 0) { + return(FALSE) + } + checked <- suppressWarnings(as.rsi(x)) + outcome <- sum(is.na(checked)) / length(x) + outcome <= threshold + } +} + #' @export as.rsi.default <- function(x, ...) { if (is.rsi(x)) { @@ -513,40 +547,6 @@ exec_as.rsi <- function(method, x, mo, ab, guideline, uti, conserve_capped_value class = c("rsi", "ordered", "factor")) } -#' @rdname as.rsi -#' @export -is.rsi <- function(x) { - inherits(x, "rsi") -} - -#' @rdname as.rsi -#' @export -is.rsi.eligible <- function(x, threshold = 0.05) { - stop_if(NCOL(x) > 1, "`x` must be a one-dimensional vector.") - - if (any(c("logical", - "numeric", - "integer", - "mo", - "Date", - "POSIXct", - "rsi", - "raw", - "hms") - %in% class(x))) { - # no transformation needed - FALSE - } else { - x <- x[!is.na(x) & !is.null(x) & !identical(x, "")] - if (length(x) == 0) { - return(FALSE) - } - checked <- suppressWarnings(as.rsi(x)) - outcome <- sum(is.na(checked)) / length(x) - outcome <= threshold - } -} - #' @method print rsi #' @export #' @noRd diff --git a/docs/404.html b/docs/404.html index a01823d6..c7406dcc 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9040 + 1.3.0 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 8f349004..b4be27d3 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9040 + 1.3.0 diff --git a/docs/articles/index.html b/docs/articles/index.html index fbf6f69c..be5e1ed2 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9040 + 1.3.0 diff --git a/docs/authors.html b/docs/authors.html index 76e206fa..904d4421 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9040 + 1.3.0 diff --git a/docs/index.html b/docs/index.html index 046ad2e1..bf61ecdb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.2.0.9040 + 1.3.0 diff --git a/docs/news/index.html b/docs/news/index.html index c30008ae..3b667526 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9040 + 1.3.0 @@ -229,14 +229,10 @@ Source: NEWS.md -
-

-AMR 1.2.0.9040 Unreleased +
+

+AMR 1.3.0 Unreleased

-
-

-Last updated: 29 July 2020 -

New

@@ -311,7 +307,6 @@
  • Moved primary location of this project from GitLab to GitHub, giving us native support for automated syntax checking without being dependent on external services such as AppVeyor and Travis CI.
  • -

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 3a612742..8e95ba84 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -10,7 +10,7 @@ articles: WHONET: WHONET.html benchmarks: benchmarks.html resistance_predict: resistance_predict.html -last_built: 2020-07-29T10:44Z +last_built: 2020-07-29T11:47Z urls: reference: https://msberends.github.io/AMR/reference article: https://msberends.github.io/AMR/articles diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index a6b94feb..2da18763 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -82,7 +82,7 @@ AMR (for R) - 1.2.0.9040 + 1.3.0

    @@ -237,6 +237,10 @@
    as.rsi(x, ...)
     
    +is.rsi(x)
    +
    +is.rsi.eligible(x, threshold = 0.05)
    +
     # S3 method for mic
     as.rsi(
       x,
    @@ -266,11 +270,7 @@
       uti = NULL,
       conserve_capped_values = FALSE,
       ...
    -)
    -
    -is.rsi(x)
    -
    -is.rsi.eligible(x, threshold = 0.05)
    +)

    Arguments

    @@ -283,6 +283,10 @@ + + + + @@ -307,10 +311,6 @@ - - - -
    ...

    parameters passed on to methods

    threshold

    maximum fraction of invalid antimicrobial interpretations of x, please see Examples

    mo

    any (vector of) text that can be coerced to a valid microorganism code with as.mo()

    col_mo

    column name of the IDs of the microorganisms (see as.mo()), defaults to the first column of class mo. Values will be coerced using as.mo().

    threshold

    maximum fraction of invalid antimicrobial interpretations of x, please see Examples

    Value

    diff --git a/docs/reference/index.html b/docs/reference/index.html index 846a848d..0e77a34c 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9040 + 1.3.0
    diff --git a/docs/reference/rsi_translation.html b/docs/reference/rsi_translation.html index 13a148bf..6d702e20 100644 --- a/docs/reference/rsi_translation.html +++ b/docs/reference/rsi_translation.html @@ -82,7 +82,7 @@ AMR (for R) - 1.2.0.9038 + 1.3.0 diff --git a/docs/survey.html b/docs/survey.html index b4939ae6..ffa8ea1a 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9040 + 1.3.0 diff --git a/man/as.rsi.Rd b/man/as.rsi.Rd index 41d310c7..ecb69c42 100755 --- a/man/as.rsi.Rd +++ b/man/as.rsi.Rd @@ -3,15 +3,19 @@ \name{as.rsi} \alias{as.rsi} \alias{rsi} +\alias{is.rsi} +\alias{is.rsi.eligible} \alias{as.rsi.mic} \alias{as.rsi.disk} \alias{as.rsi.data.frame} -\alias{is.rsi} -\alias{is.rsi.eligible} \title{Class 'rsi'} \usage{ as.rsi(x, ...) +is.rsi(x) + +is.rsi.eligible(x, threshold = 0.05) + \method{as.rsi}{mic}( x, mo, @@ -39,16 +43,14 @@ as.rsi(x, ...) conserve_capped_values = FALSE, ... ) - -is.rsi(x) - -is.rsi.eligible(x, threshold = 0.05) } \arguments{ \item{x}{vector of values (for class \code{\link{mic}}: an MIC value in mg/L, for class \code{\link{disk}}: a disk diffusion radius in millimetres)} \item{...}{parameters passed on to methods} +\item{threshold}{maximum fraction of invalid antimicrobial interpretations of \code{x}, please see \emph{Examples}} + \item{mo}{any (vector of) text that can be coerced to a valid microorganism code with \code{\link[=as.mo]{as.mo()}}} \item{ab}{any (vector of) text that can be coerced to a valid antimicrobial code with \code{\link[=as.ab]{as.ab()}}} @@ -60,8 +62,6 @@ is.rsi.eligible(x, threshold = 0.05) \item{conserve_capped_values}{a logical to indicate that MIC values starting with \code{">"} (but not \code{">="}) must always return "R" , and that MIC values starting with \code{"<"} (but not \code{"<="}) must always return "S"} \item{col_mo}{column name of the IDs of the microorganisms (see \code{\link[=as.mo]{as.mo()}}), defaults to the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.} - -\item{threshold}{maximum fraction of invalid antimicrobial interpretations of \code{x}, please see \emph{Examples}} } \value{ Ordered factor with new class \code{\link{rsi}}