# NOT RUN {
newdata <- data.frame(state=c("AL", "MI","NY"),
surname=c("Rogers", "Rogers", "Smith"),
givenName=c("Mike R.", "Mike K.", "Al"),
stringsAsFactors=FALSE)
reference <- data.frame(state=c("NY", "NY", "MI", "AL", "NY", "MI"),
surname=c("Smith", "Rogers", "Rogers (MI)",
"Rogers (AL)", "Smith", 'Jones'),
givenName=c("John", "Mike", "Mike", "Mike",
"T. Albert", 'Al Thomas'),
stringsAsFactors=FALSE)
newInRef <- match.data.frame(newdata, reference,
grep.=c(NA, 'agrep', 'agrep'))
# }
# NOT RUN {
all.equal(newInRef, c(4, 3, 5))
# }
Run the code above in your browser using DataLab