diff --git a/DESCRIPTION b/DESCRIPTION
index 51d8fb43..84422237 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,5 +1,5 @@
Package: AMR
-Version: 1.1.0.9012
+Version: 1.1.0.9013
Date: 2020-05-19
Title: Antimicrobial Resistance Analysis
Authors@R: c(
diff --git a/NAMESPACE b/NAMESPACE
index 1ab06665..0279915e 100755
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -37,8 +37,6 @@ S3method(c,rsi)
S3method(droplevels,mic)
S3method(droplevels,rsi)
S3method(format,bug_drug_combinations)
-S3method(freq,mo)
-S3method(freq,rsi)
S3method(kurtosis,data.frame)
S3method(kurtosis,default)
S3method(kurtosis,matrix)
diff --git a/NEWS.md b/NEWS.md
index 5fc07d9a..bf92cc65 100755
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,9 +1,8 @@
-# AMR 1.1.0.9012
+# AMR 1.1.0.9013
## Last updated: 19-May-2020
### Breaking
-
-* Removed code dependency on **all** R packages that this `AMR` package relied upon: `cleaner`, `crayon`, `data.table`, `dplyr`, `ggplot2`, `knitr`, `microbenchmark`, `pillar`, `R6`, `rlang`, `tidyr` and `vctrs`. This is a major code change, but will probably not be noticeable by most users.
+* Removed code dependency on **all** R packages that this `AMR` package required: `cleaner`, `crayon`, `data.table`, `dplyr`, `ggplot2`, `knitr`, `microbenchmark`, `pillar`, `R6`, `rlang`, `tidyr` and `vctrs`. This is a major code change, but will probably not be noticeable by most users.
Making this package independent on especially the tidyverse tremendously increases sustainability on the long term, since tidyverse functions change quite often. Most of our functions are replaced with versions that only rely on base R, which keeps this package fully functional for many years to come, without requiring a lot of maintenance to keep up with other packages anymore. Another upside it that this package can now be used with all versions of R since R-3.0.0 (April 2013). Our package is being used in settings where the resources are very limited. Fewer dependencies on newer software is helpful for such settings.
diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R
index defc8943..70837e7f 100755
--- a/R/aa_helper_functions.R
+++ b/R/aa_helper_functions.R
@@ -429,8 +429,8 @@ percentage <- function(x, digits = NULL, ...) {
# prevent dependency on package 'backports'
# these functions were not available in previous versions of R (last checked: R 4.0.0)
# see here for the full list: https://github.com/r-lib/backports
-strrep = function(x, times) {
- x = as.character(x)
+strrep <- function(x, times) {
+ x <- as.character(x)
if (length(x) == 0L)
return(x)
unlist(.mapply(function(x, times) {
@@ -441,18 +441,18 @@ strrep = function(x, times) {
paste0(replicate(times, x), collapse = "")
}, list(x = x, times = times), MoreArgs = list()), use.names = FALSE)
}
-trimws <- function (x, which = c("both", "left", "right")) {
- which = match.arg(which)
- mysub = function(re, x) sub(re, "", x, perl = TRUE)
+trimws <- function(x, which = c("both", "left", "right")) {
+ which <- match.arg(which)
+ mysub <- function(re, x) sub(re, "", x, perl = TRUE)
if (which == "left")
return(mysub("^[ \t\r\n]+", x))
if (which == "right")
return(mysub("[ \t\r\n]+$", x))
mysub("[ \t\r\n]+$", mysub("^[ \t\r\n]+", x))
}
-isFALSE <- function (x) {
+isFALSE <- function(x) {
is.logical(x) && length(x) == 1L && !is.na(x) && !x
}
-deparse1 = function (expr, collapse = " ", width.cutoff = 500L, ...) {
+deparse1 <- function(expr, collapse = " ", width.cutoff = 500L, ...) {
paste(deparse(expr, width.cutoff, ...), collapse = collapse)
}
diff --git a/R/ab.R b/R/ab.R
index 6bd39dff..adf56f69 100755
--- a/R/ab.R
+++ b/R/ab.R
@@ -352,7 +352,7 @@ print.ab <- function(x, ...) {
#' @exportMethod as.data.frame.ab
#' @export
#' @noRd
-as.data.frame.ab <- function (x, ...) {
+as.data.frame.ab <- function(x, ...) {
nm <- deparse1(substitute(x))
if (!"nm" %in% names(list(...))) {
as.data.frame.vector(as.ab(x), ..., nm = nm)
diff --git a/R/freq.R b/R/freq.R
deleted file mode 100755
index 13e9216c..00000000
--- a/R/freq.R
+++ /dev/null
@@ -1,72 +0,0 @@
-# ==================================================================== #
-# TITLE #
-# Antimicrobial Resistance (AMR) Analysis #
-# #
-# SOURCE #
-# https://gitlab.com/msberends/AMR #
-# #
-# LICENCE #
-# (c) 2018-2020 Berends MS, Luz CF et al. #
-# #
-# This R package is free software; you can freely use and distribute #
-# it for both personal and commercial purposes under the terms of the #
-# GNU General Public License version 2.0 (GNU GPL-2), as published by #
-# the Free Software Foundation. #
-# #
-# We created this package for both routine data analysis and academic #
-# research and it was publicly released in the hope that it will be #
-# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
-# Visit our website for more info: https://msberends.gitlab.io/AMR. #
-# ==================================================================== #
-
-if ("cleaner" %in% rownames(utils::installed.packages())) {
- freq <- get("freq", envir = asNamespace("cleaner"))
- freq.default <- get("freq.default", envir = asNamespace("cleaner"))
-} else {
- freq <- ""
- freq.default <- ""
-}
-
-#' @method freq mo
-#' @export
-#' @noRd
-freq.mo <- function(x, ...) {
- x_noNA <- as.mo(x[!is.na(x)]) # as.mo() to get the newest mo codes
- grams <- mo_gramstain(x_noNA, language = NULL)
- digits <- list(...)$digits
- if (is.null(digits)) {
- digits <- 2
- }
- freq.default(x = x, ...,
- .add_header = list(`Gram-negative` = paste0(format(sum(grams == "Gram-negative", na.rm = TRUE),
- big.mark = ",",
- decimal.mark = "."),
- " (", percentage(sum(grams == "Gram-negative", na.rm = TRUE) / length(grams), digits = digits),
- ")"),
- `Gram-positive` = paste0(format(sum(grams == "Gram-positive", na.rm = TRUE),
- big.mark = ",",
- decimal.mark = "."),
- " (", percentage(sum(grams == "Gram-positive", na.rm = TRUE) / length(grams), digits = digits),
- ")"),
- `No of genera` = n_distinct(mo_genus(x_noNA, language = NULL)),
- `No of species` = n_distinct(paste(mo_genus(x_noNA, language = NULL),
- mo_species(x_noNA, language = NULL)))))
-}
-
-#' @method freq rsi
-#' @export
-#' @noRd
-freq.rsi <- function(x, ...) {
- x_name <- deparse(substitute(x))
- x_name <- gsub(".*[$]", "", x_name)
- ab <- suppressMessages(suppressWarnings(as.ab(x_name)))
- if (!is.na(ab)) {
- freq.default(x = x, ...,
- .add_header = list(Drug = paste0(ab_name(ab), " (", ab, ", ", ab_atc(ab), ")"),
- group = ab_group(ab),
- `%SI` = susceptibility(x, minimum = 0, as_percent = TRUE)))
- } else {
- freq.default(x = x, ...,
- .add_header = list(`%SI` = susceptibility(x, minimum = 0, as_percent = TRUE)))
- }
-}
diff --git a/R/mo.R b/R/mo.R
index f51b0885..fa0e8c5f 100755
--- a/R/mo.R
+++ b/R/mo.R
@@ -1578,7 +1578,7 @@ summary.mo <- function(object, ...) {
#' @exportMethod as.data.frame.mo
#' @export
#' @noRd
-as.data.frame.mo <- function (x, ...) {
+as.data.frame.mo <- function(x, ...) {
nm <- deparse1(substitute(x))
if (!"nm" %in% names(list(...))) {
as.data.frame.vector(as.mo(x), ..., nm = nm)
diff --git a/docs/404.html b/docs/404.html
index 190e92ae..0e7c7e3f 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -81,7 +81,7 @@
NEWS.md
-
Removed code dependency on all R packages that this AMR
package relied upon: cleaner
, crayon
, data.table
, dplyr
, ggplot2
, knitr
, microbenchmark
, pillar
, R6
, rlang
, tidyr
and vctrs
. This is a major code change, but will probably not be noticeable by most users.
Removed code dependency on all R packages that this AMR
package required: cleaner
, crayon
, data.table
, dplyr
, ggplot2
, knitr
, microbenchmark
, pillar
, R6
, rlang
, tidyr
and vctrs
. This is a major code change, but will probably not be noticeable by most users.
Making this package independent on especially the tidyverse tremendously increases sustainability on the long term, since tidyverse functions change quite often. Most of our functions are replaced with versions that only rely on base R, which keeps this package fully functional for many years to come, without requiring a lot of maintenance to keep up with other packages anymore. Another upside it that this package can now be used with all versions of R since R-3.0.0 (April 2013). Our package is being used in settings where the resources are very limited. Fewer dependencies on newer software is helpful for such settings.
Negative effects of this change are: