diff --git a/DESCRIPTION b/DESCRIPTION index 9742c0c6..3d1510c4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.5.0.9033 +Version: 1.5.0.9034 Date: 2021-03-07 Title: Antimicrobial Resistance Data Analysis Authors@R: c( diff --git a/NAMESPACE b/NAMESPACE index e5e81497..dc044128 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -48,6 +48,7 @@ S3method(as.data.frame,ab) S3method(as.data.frame,mo) S3method(as.double,mic) S3method(as.integer,mic) +S3method(as.matrix,mic) S3method(as.numeric,mic) S3method(as.rsi,data.frame) S3method(as.rsi,default) @@ -308,6 +309,7 @@ export(theme_rsi) importFrom(graphics,arrows) importFrom(graphics,axis) importFrom(graphics,barplot) +importFrom(graphics,hist) importFrom(graphics,legend) importFrom(graphics,mtext) importFrom(graphics,plot) @@ -316,8 +318,10 @@ importFrom(graphics,text) importFrom(stats,complete.cases) importFrom(stats,glm) importFrom(stats,lm) +importFrom(stats,median) importFrom(stats,pchisq) importFrom(stats,prcomp) importFrom(stats,predict) importFrom(stats,qchisq) +importFrom(stats,quantile) importFrom(stats,var) diff --git a/NEWS.md b/NEWS.md index 5afc2200..1233c6ea 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.5.0.9033 +# AMR 1.5.0.9034 ## Last updated: 7 March 2021 ### New diff --git a/R/mic.R b/R/mic.R index ac724864..73a1c6d0 100755 --- a/R/mic.R +++ b/R/mic.R @@ -68,7 +68,7 @@ #' #> 10 16 A #' ``` #' -#' The following [generic functions][groupGeneric()] are implemented for the MIC class: `!`, `!=`, `%%`, `%/%`, `&`, `*`, `+`, `-`, `/`, `<`, `<=`, `==`, `>`, `>=`, `^`, `|`, [abs()], [acos()], [acosh()], [all()], [any()], [asin()], [asinh()], [atan()], [atanh()], [ceiling()], [cos()], [cosh()], [cospi()], [cummax()], [cummin()], [cumprod()], [cumsum()], [digamma()], [exp()], [expm1()], [floor()], [gamma()], [lgamma()], [log()], [log10()], [log1p()], [log2()], [max()], [mean()], [median()], [min()], [prod()], [quantile()], [range()], [round()], [sign()], [signif()], [sin()], [sinh()], [sinpi()], [sqrt()], [sum()], [tan()], [tanh()], [tanpi()], [trigamma()] and [trunc()]. +#' The following [generic functions][groupGeneric()] are implemented for the MIC class: `!`, `!=`, `%%`, `%/%`, `&`, `*`, `+`, `-`, `/`, `<`, `<=`, `==`, `>`, `>=`, `^`, `|`, [abs()], [acos()], [acosh()], [all()], [any()], [asin()], [asinh()], [atan()], [atanh()], [ceiling()], [cos()], [cosh()], [cospi()], [cummax()], [cummin()], [cumprod()], [cumsum()], [digamma()], [exp()], [expm1()], [floor()], [gamma()], [lgamma()], [log()], [log1p()], [log2()], [log10()], [max()], [mean()], [min()], [prod()], [range()], [round()], [sign()], [signif()], [sin()], [sinh()], [sinpi()], [sqrt()], [sum()], [tan()], [tanh()], [tanpi()], [trigamma()] and [trunc()]. Some functions of the `stats` package are also implemented: [median()], [quantile()], [mad()], [IQR()], [fivenum()]. Also, [boxplot.stats()] is supported. Since [sd()] and [var()] are non-generic functions, these could not be extended. Use [mad()] as an alternative, or use e.g. `sd(as.numeric(x))` where `x` is your vector of MIC values. #' @return Ordered [factor] with additional class [`mic`], that in mathematical operations acts as decimal numbers. Bare in mind that the outcome of any mathematical operation on MICs will return a numeric value. #' @aliases mic #' @export @@ -118,29 +118,29 @@ as.mic <- function(x, na.rm = FALSE) { x <- gsub("\u2264", "<=", x, fixed = TRUE) x <- gsub("\u2265", ">=", x, fixed = TRUE) # remove space between operator and number ("<= 0.002" -> "<=0.002") - x <- gsub("(<|=|>) +", "\\1", x) + x <- gsub("(<|=|>) +", "\\1", x, perl = TRUE) # transform => to >= and =< to <= x <- gsub("=<", "<=", x, fixed = TRUE) x <- gsub("=>", ">=", x, fixed = TRUE) # dots without a leading zero must start with 0 - x <- gsub("([^0-9]|^)[.]", "\\10.", x) + x <- gsub("([^0-9]|^)[.]", "\\10.", x, perl = TRUE) # values like "<=0.2560.512" should be 0.512 - x <- gsub(".*[.].*[.]", "0.", x) + x <- gsub(".*[.].*[.]", "0.", x, perl = TRUE) # remove ending .0 - x <- gsub("[.]+0$", "", x) + x <- gsub("[.]+0$", "", x, perl = TRUE) # remove all after last digit - x <- gsub("[^0-9]+$", "", x) + x <- gsub("[^0-9]+$", "", x, perl = TRUE) # keep only one zero before dot - x <- gsub("0+[.]", "0.", x) + x <- gsub("0+[.]", "0.", x, perl = TRUE) # starting 00 is probably 0.0 if there's no dot yet x[!x %like% "[.]"] <- gsub("^00", "0.0", x[!x %like% "[.]"]) # remove last zeroes - x <- gsub("([.].?)0+$", "\\1", x) - x <- gsub("(.*[.])0+$", "\\10", x) + x <- gsub("([.].?)0+$", "\\1", x, perl = TRUE) + x <- gsub("(.*[.])0+$", "\\10", x, perl = TRUE) # remove ending .0 again x[x %like% "[.]"] <- gsub("0+$", "", x[x %like% "[.]"]) # never end with dot - x <- gsub("[.]$", "", x) + x <- gsub("[.]$", "", x, perl = TRUE) # force to be character x <- as.character(x) # trim it @@ -199,21 +199,21 @@ is.mic <- function(x) { #' @export #' @noRd as.double.mic <- function(x, ...) { - as.double(gsub("[<=>]+", "", as.character(x))) + as.double(gsub("[<=>]+", "", as.character(x), perl = TRUE)) } #' @method as.integer mic #' @export #' @noRd as.integer.mic <- function(x, ...) { - as.integer(gsub("[<=>]+", "", as.character(x))) + as.integer(gsub("[<=>]+", "", as.character(x), perl = TRUE)) } #' @method as.numeric mic #' @export #' @noRd as.numeric.mic <- function(x, ...) { - as.numeric(gsub("[<=>]+", "", as.character(x))) + as.numeric(gsub("[<=>]+", "", as.character(x), perl = TRUE)) } #' @method droplevels mic @@ -263,6 +263,13 @@ summary.mic <- function(object, ...) { summary(as.double(object), ...) } +#' @method as.matrix mic +#' @export +#' @noRd +as.matrix.mic <- function(x, ...) { + as.matrix(as.double(x), ...) +} + #' @method [ mic #' @export #' @noRd @@ -328,10 +335,11 @@ sort.mic <- function(x, decreasing = FALSE, ...) { } #' @method hist mic +#' @importFrom graphics hist #' @export #' @noRd hist.mic <- function(x, ...) { - warning_("Use `plot()` or `ggplot()` for plotting MIC values", call = FALSE) + warning_("Use `plot()` or `ggplot()` for optimal plotting of MIC values", call = FALSE) hist(log2(x)) } @@ -357,18 +365,20 @@ mean.mic <- function(x, trim = 0, na.rm = FALSE, ...) { } #' @method median mic +#' @importFrom stats median #' @export #' @noRd median.mic <- function(x, na.rm = FALSE, ...) { - stats::median(as.double(x), na.rm = na.rm, ...) + median(as.double(x), na.rm = na.rm, ...) } #' @method quantile mic +#' @importFrom stats quantile #' @export #' @noRd quantile.mic <- function(x, probs = seq(0, 1, 0.25), na.rm = FALSE, names = TRUE, type = 7, ...) { - stats::quantile(as.double(x), props = props, na.rm = na.rm, names = names, type = type, ...) + quantile(as.double(x), probs = probs, na.rm = na.rm, names = names, type = type, ...) } # Math (see ?groupGeneric) ---------------------------------------------- diff --git a/R/random.R b/R/random.R index 96686f43..6917eb3b 100644 --- a/R/random.R +++ b/R/random.R @@ -121,10 +121,10 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) { } out <- as.mic(sample(set_range, size = size, replace = TRUE)) # 50% chance that lowest will get <= and highest will get >= - if (runif(1) > 0.5) { + if (stats::runif(1) > 0.5) { out[out == min(out)] <- paste0("<=", out[out == min(out)]) } - if (runif(1) > 0.5) { + if (stats::runif(1) > 0.5) { out[out == max(out)] <- paste0(">=", out[out == max(out)]) } return(out) diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 612be98d..86d05bf6 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 121dbe12..5a0580eb 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9033 + 1.5.0.9034 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 2f88e726..8b773f1a 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9033 + 1.5.0.9034 diff --git a/docs/articles/index.html b/docs/articles/index.html index 744fd485..c6f7ddf6 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9033 + 1.5.0.9034 diff --git a/docs/authors.html b/docs/authors.html index 1ab74dbe..55a547ed 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9033 + 1.5.0.9034 diff --git a/docs/index.html b/docs/index.html index c246246f..2ac30ef8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.5.0.9033 + 1.5.0.9034 diff --git a/docs/news/index.html b/docs/news/index.html index 07d91a6c..b3b4c44f 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9033 + 1.5.0.9034 @@ -236,9 +236,9 @@ Source: NEWS.md -
-

-AMR 1.5.0.9033 Unreleased +
+

+AMR 1.5.0.9034 Unreleased

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 2c3434fb..49515378 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -12,7 +12,7 @@ articles: datasets: datasets.html resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html -last_built: 2021-03-07T15:15Z +last_built: 2021-03-07T19:41Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/as.mic.html b/docs/reference/as.mic.html index d365c778..c380e679 100644 --- a/docs/reference/as.mic.html +++ b/docs/reference/as.mic.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9032 + 1.5.0.9034

@@ -295,7 +295,7 @@ #> 10 16 A -

The following generic functions are implemented for the MIC class: !, !=, %%, %/%, &, *, +, -, /, <, <=, ==, >, >=, ^, |, abs(), acos(), acosh(), all(), any(), asin(), asinh(), atan(), atanh(), ceiling(), cos(), cosh(), cospi(), cummax(), cummin(), cumprod(), cumsum(), digamma(), exp(), expm1(), floor(), gamma(), lgamma(), log(), log10(), log1p(), log2(), max(), mean(), median(), min(), prod(), quantile(), range(), round(), sign(), signif(), sin(), sinh(), sinpi(), sqrt(), sum(), tan(), tanh(), tanpi(), trigamma() and trunc().

+

The following generic functions are implemented for the MIC class: !, !=, %%, %/%, &, *, +, -, /, <, <=, ==, >, >=, ^, |, abs(), acos(), acosh(), all(), any(), asin(), asinh(), atan(), atanh(), ceiling(), cos(), cosh(), cospi(), cummax(), cummin(), cumprod(), cumsum(), digamma(), exp(), expm1(), floor(), gamma(), lgamma(), log(), log1p(), log2(), log10(), max(), mean(), min(), prod(), range(), round(), sign(), signif(), sin(), sinh(), sinpi(), sqrt(), sum(), tan(), tanh(), tanpi(), trigamma() and trunc(). Some functions of the stats package are also implemented: median(), quantile(), mad(), IQR(), fivenum(). Also, boxplot.stats() is supported. Since sd() and var() are non-generic functions, these could not be extended. Use mad() as an alternative, or use e.g. sd(as.numeric(x)) where x is your vector of MIC values.

Stable Lifecycle

diff --git a/docs/reference/index.html b/docs/reference/index.html index aee823d2..369b9960 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9033 + 1.5.0.9034
diff --git a/docs/survey.html b/docs/survey.html index ad009c63..ad060225 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9033 + 1.5.0.9034

diff --git a/man/as.mic.Rd b/man/as.mic.Rd index a4ae8090..620d5d43 100755 --- a/man/as.mic.Rd +++ b/man/as.mic.Rd @@ -54,7 +54,7 @@ subset(df, x > 4) # or with dplyr: df \%>\% filter(x > 4) #> 10 16 A } -The following \link[=groupGeneric]{generic functions} are implemented for the MIC class: \code{!}, \code{!=}, \code{\%\%}, \code{\%/\%}, \code{&}, \code{*}, \code{+}, \code{-}, \code{/}, \code{<}, \code{<=}, \code{==}, \code{>}, \code{>=}, \code{^}, \code{|}, \code{\link[=abs]{abs()}}, \code{\link[=acos]{acos()}}, \code{\link[=acosh]{acosh()}}, \code{\link[=all]{all()}}, \code{\link[=any]{any()}}, \code{\link[=asin]{asin()}}, \code{\link[=asinh]{asinh()}}, \code{\link[=atan]{atan()}}, \code{\link[=atanh]{atanh()}}, \code{\link[=ceiling]{ceiling()}}, \code{\link[=cos]{cos()}}, \code{\link[=cosh]{cosh()}}, \code{\link[=cospi]{cospi()}}, \code{\link[=cummax]{cummax()}}, \code{\link[=cummin]{cummin()}}, \code{\link[=cumprod]{cumprod()}}, \code{\link[=cumsum]{cumsum()}}, \code{\link[=digamma]{digamma()}}, \code{\link[=exp]{exp()}}, \code{\link[=expm1]{expm1()}}, \code{\link[=floor]{floor()}}, \code{\link[=gamma]{gamma()}}, \code{\link[=lgamma]{lgamma()}}, \code{\link[=log]{log()}}, \code{\link[=log10]{log10()}}, \code{\link[=log1p]{log1p()}}, \code{\link[=log2]{log2()}}, \code{\link[=max]{max()}}, \code{\link[=mean]{mean()}}, \code{\link[=median]{median()}}, \code{\link[=min]{min()}}, \code{\link[=prod]{prod()}}, \code{\link[=quantile]{quantile()}}, \code{\link[=range]{range()}}, \code{\link[=round]{round()}}, \code{\link[=sign]{sign()}}, \code{\link[=signif]{signif()}}, \code{\link[=sin]{sin()}}, \code{\link[=sinh]{sinh()}}, \code{\link[=sinpi]{sinpi()}}, \code{\link[=sqrt]{sqrt()}}, \code{\link[=sum]{sum()}}, \code{\link[=tan]{tan()}}, \code{\link[=tanh]{tanh()}}, \code{\link[=tanpi]{tanpi()}}, \code{\link[=trigamma]{trigamma()}} and \code{\link[=trunc]{trunc()}}. +The following \link[=groupGeneric]{generic functions} are implemented for the MIC class: \code{!}, \code{!=}, \code{\%\%}, \code{\%/\%}, \code{&}, \code{*}, \code{+}, \code{-}, \code{/}, \code{<}, \code{<=}, \code{==}, \code{>}, \code{>=}, \code{^}, \code{|}, \code{\link[=abs]{abs()}}, \code{\link[=acos]{acos()}}, \code{\link[=acosh]{acosh()}}, \code{\link[=all]{all()}}, \code{\link[=any]{any()}}, \code{\link[=asin]{asin()}}, \code{\link[=asinh]{asinh()}}, \code{\link[=atan]{atan()}}, \code{\link[=atanh]{atanh()}}, \code{\link[=ceiling]{ceiling()}}, \code{\link[=cos]{cos()}}, \code{\link[=cosh]{cosh()}}, \code{\link[=cospi]{cospi()}}, \code{\link[=cummax]{cummax()}}, \code{\link[=cummin]{cummin()}}, \code{\link[=cumprod]{cumprod()}}, \code{\link[=cumsum]{cumsum()}}, \code{\link[=digamma]{digamma()}}, \code{\link[=exp]{exp()}}, \code{\link[=expm1]{expm1()}}, \code{\link[=floor]{floor()}}, \code{\link[=gamma]{gamma()}}, \code{\link[=lgamma]{lgamma()}}, \code{\link[=log]{log()}}, \code{\link[=log1p]{log1p()}}, \code{\link[=log2]{log2()}}, \code{\link[=log10]{log10()}}, \code{\link[=max]{max()}}, \code{\link[=mean]{mean()}}, \code{\link[=min]{min()}}, \code{\link[=prod]{prod()}}, \code{\link[=range]{range()}}, \code{\link[=round]{round()}}, \code{\link[=sign]{sign()}}, \code{\link[=signif]{signif()}}, \code{\link[=sin]{sin()}}, \code{\link[=sinh]{sinh()}}, \code{\link[=sinpi]{sinpi()}}, \code{\link[=sqrt]{sqrt()}}, \code{\link[=sum]{sum()}}, \code{\link[=tan]{tan()}}, \code{\link[=tanh]{tanh()}}, \code{\link[=tanpi]{tanpi()}}, \code{\link[=trigamma]{trigamma()}} and \code{\link[=trunc]{trunc()}}. Some functions of the \code{stats} package are also implemented: \code{\link[=median]{median()}}, \code{\link[=quantile]{quantile()}}, \code{\link[=mad]{mad()}}, \code{\link[=IQR]{IQR()}}, \code{\link[=fivenum]{fivenum()}}. Also, \code{\link[=boxplot.stats]{boxplot.stats()}} is supported. Since \code{\link[=sd]{sd()}} and \code{\link[=var]{var()}} are non-generic functions, these could not be extended. Use \code{\link[=mad]{mad()}} as an alternative, or use e.g. \code{sd(as.numeric(x))} where \code{x} is your vector of MIC values. } \section{Stable Lifecycle}{