From 3a5d8500bfe352ca7429f90688ae699f0a4ffb4e Mon Sep 17 00:00:00 2001 From: bemts-hhs Date: Thu, 18 Jun 2026 09:58:55 -0500 Subject: [PATCH 1/4] deprecate %not_in% with a warning due to release of base R %notin% in April 2026 via v4.6.0 --- R/not_in.r | 17 ++++- man/grapes-not_in-grapes.Rd | 8 ++- tests/testthat/test-not_in.R | 116 +++++++++++++++++++++-------------- 3 files changed, 90 insertions(+), 51 deletions(-) diff --git a/R/not_in.r b/R/not_in.r index 7f3ebc4..210641d 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/man/grapes-not_in-grapes.Rd b/man/grapes-not_in-grapes.Rd index 80bd8f3..903c576 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) }) From c9e356f317f913166653a7cc1c79751a227e32c8 Mon Sep 17 00:00:00 2001 From: bemts-hhs Date: Thu, 18 Jun 2026 10:20:28 -0500 Subject: [PATCH 2/4] Increment version number to 1.2.7 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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..9242ee0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# traumar (development version) +# traumar 1.2.7 # traumar 1.2.6 - Deprecate the `n_decimal` argument for `pretty_number()`, use `digits` From 223a568e5ea2906bcfeefdeff21439403af547dd Mon Sep 17 00:00:00 2001 From: bemts-hhs Date: Thu, 18 Jun 2026 13:13:26 -0500 Subject: [PATCH 3/4] update NEWS and not_in documentation --- NEWS.md | 3 +++ R/not_in.r | 2 +- man/grapes-not_in-grapes.Rd | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9242ee0..404944f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,7 @@ # 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 210641d..1e2a090 100644 --- a/R/not_in.r +++ b/R/not_in.r @@ -3,7 +3,7 @@ #' @description #' `r lifecycle::badge("deprecated")` #' -#' `%not_in%` has been **deprecated** because base R (≥ 4.6.0) now provides the +#' `%not_in%` has been **deprecated** because base R (>= 4.6.0) now provides the #' `%notin%` operator. #' #' Please use `%notin%` from `base` instead. diff --git a/man/grapes-not_in-grapes.Rd b/man/grapes-not_in-grapes.Rd index 903c576..82a2209 100644 --- a/man/grapes-not_in-grapes.Rd +++ b/man/grapes-not_in-grapes.Rd @@ -19,7 +19,7 @@ it is found in \code{y}. \description{ \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{\%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. From 2001db6a9fa79abeb3573ac0561c5ae56c7748ee Mon Sep 17 00:00:00 2001 From: bemts-hhs Date: Thu, 18 Jun 2026 13:28:35 -0500 Subject: [PATCH 4/4] update cran-comments --- cran-comments.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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