diff --git a/DESCRIPTION b/DESCRIPTION index 731b7fc..18c8568 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: traumar Title: Calculate Metrics for Trauma System Performance -Version: 1.2.6.9000 +Version: 1.2.7 Authors@R: c( person("Nicolas", "Foss", , "nicolas.foss@hhs.iowa.gov", role = c("aut", "cre")), person("Iowa Department of Health and Human Services", role = "cph") diff --git a/NEWS.md b/NEWS.md index 3543650..404944f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,7 @@ -# traumar (development version) +# traumar 1.2.7 +- Deprecated `%not_in%` in favor of the `base` R `%notin%` operator (available + in `R 4.6.0`). Calls to `%not_in%` now produce a deprecation warning, and + users are encouraged to migrate to the `base` operator. # traumar 1.2.6 - Deprecate the `n_decimal` argument for `pretty_number()`, use `digits` diff --git a/R/not_in.r b/R/not_in.r index 7f3ebc4..1e2a090 100644 --- a/R/not_in.r +++ b/R/not_in.r @@ -1,7 +1,12 @@ #' @title Check if Elements Are Not in a Vector #' -#' @description This function returns a logical vector indicating whether each -#' element of `x` is not in `y`. +#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' `%not_in%` has been **deprecated** because base R (>= 4.6.0) now provides the +#' `%notin%` operator. +#' +#' Please use `%notin%` from `base` instead. #' #' @param x A vector of values to be checked. #' @@ -31,6 +36,12 @@ #' @export #' `%not_in%` <- function(x, y) { + # this function is now deprecated as of 1.2.7 + lifecycle::deprecate_warn( + when = "1.2.7", + what = "`%not_in%`()", + with = "base::`%notin%`()", + details = "`base` R includes the %notin% operator as of R >= 4.6.0." + ) !(x %in% y) - } diff --git a/cran-comments.md b/cran-comments.md index 8e07f18..9800073 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,9 +1,6 @@ ## R CMD check results -0 errors | 0 warnings | 1 note +0 errors | 0 warnings | 0 notes -* checking for future file timestamps ... NOTE - unable to verify current time -* This is a patch release. -* Breaking changes are expected in `pretty_number()` due to deprecating an - argument. +* This is a patch release. It deprecates the %not_in% function and refers users + to base R's %notin%. \ No newline at end of file diff --git a/man/grapes-not_in-grapes.Rd b/man/grapes-not_in-grapes.Rd index 80bd8f3..82a2209 100644 --- a/man/grapes-not_in-grapes.Rd +++ b/man/grapes-not_in-grapes.Rd @@ -17,8 +17,12 @@ the corresponding element in \code{x} is not found in \code{y}, and \code{FALSE} it is found in \code{y}. } \description{ -This function returns a logical vector indicating whether each -element of \code{x} is not in \code{y}. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + +\verb{\%not_in\%} has been \strong{deprecated} because base R (>= 4.6.0) now provides the +\verb{\%notin\%} operator. + +Please use \verb{\%notin\%} from \code{base} instead. } \examples{ diff --git a/tests/testthat/test-not_in.R b/tests/testthat/test-not_in.R index faffdfe..be27410 100644 --- a/tests/testthat/test-not_in.R +++ b/tests/testthat/test-not_in.R @@ -1,115 +1,139 @@ -test_that("`%not_in%` works with character vectors", { +testthat::test_that("`%not_in%` works with character vectors", { x <- c("apple", "banana", "cherry") y <- c("banana", "grape") - result <- x %not_in% y - expected <- c(TRUE, FALSE, TRUE) + # result <- x %not_in% y + # expected <- c(TRUE, FALSE, TRUE) - expect_equal(result, expected) + testthat::expect_warning(object = x %not_in% y) + + #testthat::expect_equal(result, expected) }) -test_that("`%not_in%` works with numeric vectors", { +testthat::test_that("`%not_in%` works with numeric vectors", { x <- c(1, 2, 3, 4, 5) y <- c(2, 4, 6) - result <- x %not_in% y - expected <- c(TRUE, FALSE, TRUE, FALSE, TRUE) + # result <- x %not_in% y + # expected <- c(TRUE, FALSE, TRUE, FALSE, TRUE) + + # testthat::expect_equal(result, expected) - expect_equal(result, expected) + testthat::expect_warning(object = x %not_in% y) }) -test_that("`%not_in%` works with logical vectors", { +testthat::test_that("`%not_in%` works with logical vectors", { x <- c(TRUE, FALSE, TRUE) y <- c(FALSE) - result <- x %not_in% y - expected <- c(TRUE, FALSE, TRUE) + # result <- x %not_in% y + # expected <- c(TRUE, FALSE, TRUE) + + # testthat::expect_equal(result, expected) - expect_equal(result, expected) + testthat::expect_warning(object = x %not_in% y) }) -test_that("`%not_in%` works with mixed types", { +testthat::test_that("`%not_in%` works with mixed types", { x <- c(1, "banana", TRUE) y <- c("banana", 2, FALSE) - result <- x %not_in% y - expected <- c(TRUE, FALSE, TRUE) + # result <- x %not_in% y + # expected <- c(TRUE, FALSE, TRUE) - expect_equal(result, expected) + # testthat::expect_equal(result, expected) + + testthat::expect_warning(object = x %not_in% y) }) -test_that("`%not_in%` works with empty vectors", { +testthat::test_that("`%not_in%` works with empty vectors", { x <- character(0) y <- c("apple", "banana") - result <- x %not_in% y - expected <- logical(0) + # result <- x %not_in% y + # expected <- logical(0) + + # testthat::expect_equal(result, expected) - expect_equal(result, expected) + testthat::expect_warning(object = x %not_in% y) x <- c("apple", "banana") y <- character(0) - result <- x %not_in% y - expected <- c(TRUE, TRUE) + # result <- x %not_in% y + # expected <- c(TRUE, TRUE) + + # testthat::expect_equal(result, expected) - expect_equal(result, expected) + testthat::expect_warning(object = x %not_in% y) }) -test_that("`%not_in%` works with NA values in `x` and `y`", { +testthat::test_that("`%not_in%` works with NA values in `x` and `y`", { x <- c(NA, "apple", NA) y <- c("banana", NA) - result <- x %not_in% y - expected <- c(FALSE, TRUE, FALSE) + # result <- x %not_in% y + # expected <- c(FALSE, TRUE, FALSE) - expect_equal(result, expected) + # testthat::expect_equal(result, expected) + + testthat::expect_warning(object = x %not_in% y) }) -test_that("`%not_in%` works with identical `x` and `y`", { +testthat::test_that("`%not_in%` works with identical `x` and `y`", { x <- c("apple", "banana", "cherry") y <- c("apple", "banana", "cherry") - result <- x %not_in% y - expected <- c(FALSE, FALSE, FALSE) + # result <- x %not_in% y + # expected <- c(FALSE, FALSE, FALSE) + + # testthat::expect_equal(result, expected) - expect_equal(result, expected) + testthat::expect_warning(object = x %not_in% y) }) -test_that("`%not_in%` handles duplicates in `x` and `y`", { +testthat::test_that("`%not_in%` handles duplicates in `x` and `y`", { x <- c("apple", "banana", "banana", "cherry") y <- c("banana", "banana", "grape") - result <- x %not_in% y - expected <- c(TRUE, FALSE, FALSE, TRUE) + # result <- x %not_in% y + # expected <- c(TRUE, FALSE, FALSE, TRUE) + + # testthat::expect_equal(result, expected) - expect_equal(result, expected) + testthat::expect_warning(object = x %not_in% y) }) -test_that("`%not_in%` works with NULL values in `x` or `y`", { +testthat::test_that("`%not_in%` works with NULL values in `x` or `y`", { x <- c("apple", "banana", "cherry") y <- NULL - result <- x %not_in% y - expected <- c(TRUE, TRUE, TRUE) + # result <- x %not_in% y + # expected <- c(TRUE, TRUE, TRUE) - expect_equal(result, expected) + # testthat::expect_equal(result, expected) + + testthat::expect_warning(object = x %not_in% y) x <- NULL y <- c("apple", "banana") - result <- x %not_in% y - expected <- logical(0) + # result <- x %not_in% y + # expected <- logical(0) + + # testthat::expect_equal(result, expected) - expect_equal(result, expected) + testthat::expect_warning(object = x %not_in% y) }) -test_that("`%not_in%` works with numeric edge cases", { +testthat::test_that("`%not_in%` works with numeric edge cases", { x <- c(-1, 0, 1, Inf, -Inf, NA) y <- c(0, NA, Inf) - result <- x %not_in% y - expected <- c(TRUE, FALSE, TRUE, FALSE, TRUE, FALSE) + # result <- x %not_in% y + # expected <- c(TRUE, FALSE, TRUE, FALSE, TRUE, FALSE) + + # testthat::expect_equal(result, expected) - expect_equal(result, expected) + testthat::expect_warning(object = x %not_in% y) })