diff --git a/DESCRIPTION b/DESCRIPTION index 8b3420757..4fb8a4741 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 b281a6679..35b246139 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 ee2eae436..447fc94ff 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 a01823d6a..c7406dcca 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 8f349004c..b4be27d3a 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 fbf6f69c4..be5e1ed2f 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 76e206fad..904d4421c 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 046ad2e16..bf61ecdb9 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 c30008aea..3b6675265 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 3a6127423..8e95ba84f 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 a6b94feb0..2da187634 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 846a848d3..0e77a34cb 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 13a148bff..6d702e202 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 b4939ae63..ffa8ea1a3 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 41d310c77..ecb69c42b 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}}