diff --git a/DESCRIPTION b/DESCRIPTION index bf62ac5b..5673c51d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.6.0.9061 -Date: 2021-05-23 +Version: 1.6.0.9062 +Date: 2021-05-24 Title: Antimicrobial Resistance Data Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 87de423e..acbd2547 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# `AMR` 1.6.0.9061 -## Last updated: 23 May 2021 +# `AMR` 1.6.0.9062 +## Last updated: 24 May 2021 ### Breaking change * All antibiotic class selectors (such as `carbapenems()`, `aminoglycosides()`) can now be used for filtering as well, making all their accompanying `filter_*()` functions redundant (such as `filter_carbapenems()`, `filter_aminoglycosides()`). These functions are now deprecated and will be removed in a next release. diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 646bbeba..adbb3454 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -727,7 +727,7 @@ get_current_data <- function(arg_name, call) { } } - if (current_R_older_than(3.2)) { + if (getRversion() < "3.2") { # R-3.0 and R-3.1 do not have an `x` element in the call stack, rendering this function useless if (is.na(arg_name)) { # like in carbapenems() etc. @@ -893,7 +893,7 @@ has_colour <- function() { if (Sys.getenv("RSTUDIO", "") == "") { return(FALSE) } - if ((cols <- Sys.getenv("RSTUDIO_CONSOLE_COLOR", "")) != "" && !is.na(as.numeric(cols))) { + if ((cols <- Sys.getenv("RSTUDIO_CONSOLE_COLOR", "")) != "" && !is.na(as.double(cols))) { return(TRUE) } tryCatch(get("isAvailable", envir = asNamespace("rstudioapi"))(), error = function(e) return(FALSE)) && @@ -1186,15 +1186,11 @@ percentage <- function(x, digits = NULL, ...) { } time_start_tracking <- function() { - pkg_env$time_start <- round(as.numeric(Sys.time()) * 1000) + pkg_env$time_start <- round(as.double(Sys.time()) * 1000) } time_track <- function(name = NULL) { - paste("(until now:", trimws(round(as.numeric(Sys.time()) * 1000) - pkg_env$time_start), "ms)") -} - -current_R_older_than <- function(version) { - as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < version + paste("(until now:", trimws(round(as.double(Sys.time()) * 1000) - pkg_env$time_start), "ms)") } # prevent dependency on package 'backports' ---- @@ -1245,7 +1241,7 @@ lengths <- function(x, use.names = TRUE) { vapply(x, length, FUN.VALUE = NA_integer_, USE.NAMES = use.names) } -if (current_R_older_than(3.1)) { +if (getRversion() < "3.1") { # R-3.0 does not contain these functions, set them here to prevent installation failure # (required for extension of the class) cospi <- function(...) 1 diff --git a/R/ab_class_selectors.R b/R/ab_class_selectors.R index 80126fc7..5e18a91e 100644 --- a/R/ab_class_selectors.R +++ b/R/ab_class_selectors.R @@ -25,11 +25,11 @@ #' Antibiotic Class Selectors #' -#' These functions help to filter and select columns with antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} +#' These functions help to filter and select columns with antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \strong{\Sexpr{ifelse(getRversion() < "3.2", paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} #' @inheritSection lifecycle Stable Lifecycle #' @param ab_class an antimicrobial class, such as `"carbapenems"`. The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched (case-insensitive) for this value. #' @param only_rsi_columns a [logical] to indicate whether only columns of class `` must be selected (defaults to `FALSE`), see [as.rsi()] -#' @details \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} +#' @details \strong{\Sexpr{ifelse(getRversion() < "3.2", paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} #' #' #' These functions can be used in data set calls for selecting columns and filtering rows, see *Examples*. They support base R, but work more convenient in dplyr functions such as [`select()`][dplyr::select()], [`filter()`][dplyr::filter()] and [`summarise()`][dplyr::summarise()]. @@ -220,7 +220,7 @@ ab_selector <- function(ab_class, meet_criteria(function_name, allow_class = "character", has_length = 1, .call_depth = 1) meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1, .call_depth = 1) - if (current_R_older_than(3.2)) { + if (getRversion() < "3.2") { warning_("antibiotic class selectors such as ", function_name, "() require R version 3.2 or later - you have ", R.version.string, call = FALSE) diff --git a/R/age.R b/R/age.R index 849b467c..9864bf4a 100755 --- a/R/age.R +++ b/R/age.R @@ -75,11 +75,16 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) { # add decimals if (exact == TRUE) { # get dates of `x` when `x` would have the year of `reference` - x_in_reference_year <- as.POSIXlt(paste0(format(as.Date(reference), "%Y"), format(as.Date(x), "-%m-%d"))) + x_in_reference_year <- as.POSIXlt(paste0(format(as.Date(reference), "%Y"), + format(as.Date(x), "-%m-%d")), + format = "%Y-%m-%d") # get differences in days - n_days_x_rest <- as.double(difftime(as.Date(reference), as.Date(x_in_reference_year), units = "days")) + n_days_x_rest <- as.double(difftime(as.Date(reference), + as.Date(x_in_reference_year), + units = "days")) # get numbers of days the years of `reference` has for a reliable denominator - n_days_reference_year <- as.POSIXlt(paste0(format(as.Date(reference), "%Y"), "-12-31"))$yday + 1 + n_days_reference_year <- as.POSIXlt(paste0(format(as.Date(reference), "%Y"), "-12-31"), + format = "%Y-%m-%d")$yday + 1 # add decimal parts of year mod <- n_days_x_rest / n_days_reference_year # negative mods are cases where `x_in_reference_year` > `reference` - so 'add' a year @@ -100,7 +105,11 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE, ...) { ages <- ages[!is.na(ages)] } - ages + if (exact == TRUE) { + as.double(ages) + } else { + as.integer(ages) + } } #' Split Ages into Age Groups diff --git a/R/disk.R b/R/disk.R index a5a6f502..0f901bd8 100644 --- a/R/disk.R +++ b/R/disk.R @@ -85,7 +85,7 @@ as.disk <- function(x, na.rm = FALSE) { fixed = TRUE) x_clean <- gsub(remove, "", x, ignore.case = TRUE, fixed = fixed) # remove everything that is not a number or dot - as.numeric(gsub("[^0-9.]+", "", x_clean)) + as.double(gsub("[^0-9.]+", "", x_clean)) } # round up and make it an integer diff --git a/R/pca.R b/R/pca.R index 7fef85b6..426be37d 100755 --- a/R/pca.R +++ b/R/pca.R @@ -120,7 +120,7 @@ pca <- function(x, message_("Columns selected for PCA: ", vector_and(font_bold(colnames(pca_data), collapse = NULL), quotes = TRUE), ". Total observations available: ", nrow(pca_data), ".") - if (current_R_older_than(3.4)) { + if (getRversion() < "3.4.0") { # stats::prcomp prior to 3.4.0 does not have the 'rank.' argument pca_model <- prcomp(pca_data, retx = retx, center = center, scale. = scale., tol = tol) } else { diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 7fe3d414..6145c3bf 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 52bf38b9..8accef26 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9061 + 1.6.0.9062 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index fe7fda44..c662a42c 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9061 + 1.6.0.9062 diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 8cc857e5..02aebe2c 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -39,7 +39,7 @@ AMR (for R) - 1.6.0.9061 + 1.6.0.9062 @@ -192,7 +192,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 967b41fd..fd8f40a9 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9061 + 1.6.0.9062 diff --git a/docs/index.html b/docs/index.html index b3613817..f9ad8d26 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 1.6.0.9061 + 1.6.0.9062 diff --git a/docs/news/index.html b/docs/news/index.html index 95babb9a..114a77ed 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9061 + 1.6.0.9062 @@ -236,12 +236,12 @@ Source: NEWS.md -
-

- Unreleased AMR 1.6.0.9061

-
+
+

+ Unreleased AMR 1.6.0.9062

+

-Last updated: 23 May 2021 +Last updated: 24 May 2021

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index ec8a439e..2e8f5574 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-05-23T20:10Z +last_built: 2021-05-23T22:05Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/antibiotic_class_selectors.html b/docs/reference/antibiotic_class_selectors.html index c232f49c..9ec2e887 100644 --- a/docs/reference/antibiotic_class_selectors.html +++ b/docs/reference/antibiotic_class_selectors.html @@ -83,7 +83,7 @@ AMR (for R) - 1.6.0.9061 + 1.6.0.9062

diff --git a/docs/reference/index.html b/docs/reference/index.html index 79a67d6a..4029fbd2 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9061 + 1.6.0.9062
diff --git a/docs/survey.html b/docs/survey.html index f756d1d6..76b36551 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9061 + 1.6.0.9062
diff --git a/inst/tinytest/test-ab_class_selectors.R b/inst/tinytest/test-ab_class_selectors.R index c2e5babf..594807bd 100644 --- a/inst/tinytest/test-ab_class_selectors.R +++ b/inst/tinytest/test-ab_class_selectors.R @@ -23,7 +23,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -if (!AMR:::current_R_older_than(3.2)) { +if (getRversion() >= "3.2") { # antibiotic class selectors require at least R-3.2 expect_true(ncol(example_isolates[, aminoglycosides(), drop = FALSE]) < ncol(example_isolates)) expect_true(ncol(example_isolates[, betalactams(), drop = FALSE]) < ncol(example_isolates)) diff --git a/inst/tinytest/test-mic.R b/inst/tinytest/test-mic.R index 501b1dc9..cc242b9e 100755 --- a/inst/tinytest/test-mic.R +++ b/inst/tinytest/test-mic.R @@ -85,7 +85,7 @@ suppressWarnings(expect_identical(log1p(x), log1p(x_double))) suppressWarnings(expect_identical(cos(x), cos(x_double))) suppressWarnings(expect_identical(sin(x), sin(x_double))) suppressWarnings(expect_identical(tan(x), tan(x_double))) -if (!AMR:::current_R_older_than(3.1)) { +if (getRversion() >= "3.1") { suppressWarnings(expect_identical(cospi(x), cospi(x_double))) suppressWarnings(expect_identical(sinpi(x), sinpi(x_double))) suppressWarnings(expect_identical(tanpi(x), tanpi(x_double))) diff --git a/man/antibiotic_class_selectors.Rd b/man/antibiotic_class_selectors.Rd index 2f028977..181cc9bb 100644 --- a/man/antibiotic_class_selectors.Rd +++ b/man/antibiotic_class_selectors.Rd @@ -58,10 +58,10 @@ tetracyclines(only_rsi_columns = FALSE) \item{only_rsi_columns}{a \link{logical} to indicate whether only columns of class \verb{} must be selected (defaults to \code{FALSE}), see \code{\link[=as.rsi]{as.rsi()}}} } \description{ -These functions help to filter and select columns with antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} +These functions help to filter and select columns with antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \strong{\Sexpr{ifelse(getRversion() < "3.2", paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} } \details{ -\strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} +\strong{\Sexpr{ifelse(getRversion() < "3.2", paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} These functions can be used in data set calls for selecting columns and filtering rows, see \emph{Examples}. They support base R, but work more convenient in dplyr functions such as \code{\link[dplyr:select]{select()}}, \code{\link[dplyr:filter]{filter()}} and \code{\link[dplyr:summarise]{summarise()}}. diff --git a/tests/tinytest.R b/tests/tinytest.R index 0155b0a4..57d0c555 100644 --- a/tests/tinytest.R +++ b/tests/tinytest.R @@ -27,9 +27,7 @@ if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) { # env var 'R_LIBS_USER' got overwritten during 'R CMD check' in GitHub Actions, so: .libPaths(c(Sys.getenv("R_LIBS_USER_GH_ACTIONS"), .libPaths())) - print("here") if (AMR:::pkg_is_available("tinytest")) { - print("here2") library(AMR) out <- test_package("AMR", testdir = ifelse(AMR:::dir.exists("inst/tinytest"),