patternapply

Iteratively try patterns against a character vector.
git clone https://git.eamoncaddigan.net/patternapply.git
Log | Files | Refs | README | LICENSE

test_countPatternMatches.R (417B)


      1 library(patternapply)
      2 context("countPatternMatches")
      3 
      4 test_that("countPatternMatches", {
      5   expect_equal(as.vector(countPatternMatches(paste(seq(0,99)), paste(seq(0,9)))), 
      6                c(10, rep(19, 9)))
      7   expect_equal(as.vector(countPatternMatches(letters, letters)), 
      8                rep(1, length(letters)))
      9   expect_equal(as.vector(countPatternMatches("abc", c("^a", "^b", "^."))),
     10                c(1, 0, 1))
     11 })