# NOT RUN {
##
## 1. common examples
##
x2match <- c('Pete', 'Peter', 'Ma', 'Mo', 'Paul',
'Cardenas')
tbl <- c('Peter', 'Mary', 'Martha', 'John Paul', 'Peter',
'Cardenas', 'Cardenas')
x2mtchd <- pmatch2(x2match, tbl)
# answer
x2mtchd. <- list(Pete=c(1, 5), Peter=c(1, 5), Ma=2:3,
Mo=integer(0), Paul=4, Cardenas=6:7)
# }
# NOT RUN {
all.equal(x2mtchd, x2mtchd.)
# }
# NOT RUN {
##
## 2. strange cases that caused errors and are now warnings
##
huh <- pmatch2("(7", tbl)
# answer
huh. <- list("(7"=integer(0))
# }
# NOT RUN {
all.equal(huh, huh.)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab