diff --git a/DESCRIPTION b/DESCRIPTION index 20cf55d..5961f25 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,7 +3,7 @@ Type: Package Title: Safe, Multiple, Simultaneous String Substitution Version: 2.0.0 Authors@R: c( - person("Mark", "Ewing", email="b.mark@ewingsonline.com", role=c("aut","cre")) + person("Mark", "Ewing", email="b.mark.ewing@gmail.com", role=c("aut","cre")) ) BugReports: https://github.com/bmewing/mgsub/issues Description: Designed to enable simultaneous substitution in strings in a safe fashion. @@ -11,9 +11,9 @@ Description: Designed to enable simultaneous substitution in strings in a safe f License: MIT + file LICENSE Encoding: UTF-8 ByteCompile: true -RoxygenNote: 7.3.3 Suggests: testthat, knitr, rmarkdown VignetteBuilder: knitr URL: https://github.com/bmewing/mgsub, https://bmewing.github.io/mgsub/ +Config/roxygen2/version: 8.0.0 diff --git a/NEWS.md b/NEWS.md index 9101c7e..7e13297 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ * Rewrote key functions in C to provide significant performance boost (4-5x speedup in certain tests) * `get_matches` and `filter_overlap` are the primary performance enhancers * `get_matches_base` and `filter_overlap_base` retain the original base R functionality in case of issues with building the code +* Changed maintainer email address because current one was bouncing CRAN emails # mgsub 1.7.3 * Vignettes were using the qdap package which was not available causing errors. This update only modifies the vignette to remove the use of qdap (and microbenchmark) and so these were removed from the 'suggests'. @@ -17,7 +18,7 @@ # mgsub 1.7 * Added the mgsub_censor function which enables fast, simultaneous censoring of patterns -* Trimmed unncessary logic and helper functions +* Trimmed unnecessary logic and helper functions # mgsub 1.6 diff --git a/R/helper_functions.R b/R/helper_functions.R index 10594dc..2e878f0 100644 --- a/R/helper_functions.R +++ b/R/helper_functions.R @@ -55,6 +55,10 @@ collect_matches = function(string, pattern, ...) { if (length(pattern) == 0) { return(collect_matches_base(string, pattern, ...)) } + + if (any(is.numeric(pattern))) { + pattern[is.numeric(pattern)] = as.character(pattern[is.numeric(pattern)]) + } if (has_collect_matches_native()) { return(.Call("_mgsub_collect_matches_cpp", string, pattern, list(...), diff --git a/R/mgsub.R b/R/mgsub.R index 386160e..6278b7a 100644 --- a/R/mgsub.R +++ b/R/mgsub.R @@ -26,6 +26,7 @@ mgsub = function(string, pattern, replacement, recycle=FALSE, ...) { if (all(is.na(string))) return(string) sna = !is.na(string) + sn = is.numeric(string) if (!is.logical(recycle)) stop("Recycle must be a boolean") if (!recycle & length(pattern) != length(replacement)) { stop("pattern and replacement vectors must be the same length") @@ -40,6 +41,7 @@ mgsub = function(string, pattern, replacement, recycle=FALSE, ...) { lr = length(replacement) replacement = rep(replacement, ceiling(lp / lr))[seq_along(pattern)] } + result = vapply(X = string[sna], FUN = worker, FUN.VALUE = c(""), diff --git a/cran-comments.md b/cran-comments.md index 9fd4ba0..802ec6b 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,10 +1,16 @@ ## Test environments -* local Windows install, R 4.5.0 -* Windows Server 2025 (via Github Actions), R 4.5.3 -* MacOS 15.7.4 (via Github Actions), R 4.5.3 +* local Windows install, R 4.6.0 +* Windows Server 2025 (via Github Actions), R 4.6.0 +* MacOS 15.7.4 (via Github Actions), R 4.6.0 +* ubuntu 24.04.4 LTS (via Github Actions), R 4.6.0 * ubuntu 24.04.4 LTS (via Github Actions), R 4.5.3 -* ubuntu 24.04.4 LTS (via Github Actions), R 4.4.3 * ubuntu 24.04.4 LTS (via Github Actions), R-devel ## R CMD check results There were no ERRORs or WARNINGs. + +## Updating maintainer email (this is the NOTE in my check) +I was informed by a maintainer of a downstream package that mgsub +was set to be delisted because CRAN emails were bouncing. I have +been having sporadic issues with my ewingsonline.com domain and +so switched to `b.mark.ewing@gmail.com` in order to address this. \ No newline at end of file diff --git a/man/mgsub-package.Rd b/man/mgsub-package.Rd index 5590b0a..866f026 100644 --- a/man/mgsub-package.Rd +++ b/man/mgsub-package.Rd @@ -11,12 +11,18 @@ Designed to enable simultaneous substitution in strings in a safe fashion. Safe Useful links: \itemize{ \item \url{https://github.com/bmewing/mgsub} + \item \url{https://bmewing.github.io/mgsub/} \item Report bugs at \url{https://github.com/bmewing/mgsub/issues} } } \author{ -\strong{Maintainer}: Mark Ewing \email{b.mark@ewingsonline.com} +\strong{Maintainer}: Mark Ewing \email{b.mark.ewing@gmail.com} + +Authors: +\itemize{ + \item Mark Ewing \email{b.mark.ewing@gmail.com} +} } \keyword{internal} diff --git a/src/get_matches.o b/src/get_matches.o index 98daf84..bb0ac81 100644 Binary files a/src/get_matches.o and b/src/get_matches.o differ diff --git a/src/mgsub.dll b/src/mgsub.dll index 86fc3ef..90cc00f 100644 Binary files a/src/mgsub.dll and b/src/mgsub.dll differ diff --git a/src/resolve_matches.o b/src/resolve_matches.o index 461b58d..19daf7a 100644 Binary files a/src/resolve_matches.o and b/src/resolve_matches.o differ diff --git a/tests/testthat/test_mgsub.R b/tests/testthat/test_mgsub.R index b702c07..c01eada 100644 --- a/tests/testthat/test_mgsub.R +++ b/tests/testthat/test_mgsub.R @@ -36,6 +36,16 @@ test_that("NAs are correctly handled", { expect_equal(mgsub(c("string", NA, "test"), c("t"), c("p")), c("spring", NA, "pesp")) }) +test_that("numeric input is handled gracefully", { + expect_equal(mgsub("I live in the 37664 zip code but I'm moving to 99516", + pattern = 37664, replacement=37660), + "I live in the 37660 zip code but I'm moving to 99516") + expect_equal(mgsub("I live in the 37664 zip code but I'm moving to 99516", + pattern = c(37664, "99516"), replacement=c("37660", 58126)), + "I live in the 37660 zip code but I'm moving to 58126") + expect_equal(mgsub(123414, 4, "a"), "123a1a") +}) + test_that("recylce has to be a boolean", { expect_error(mgsub("hey, ho", c("hey"), c("ho", "hey"), recycle = "yes")) expect_error(mgsub("hey, ho", c("hey"), c("ho", "hey"), recycle = 1))