Well I can get that error message by supplying ""
to pattern. as seen here but not with other potentially bad patterns:
agrep("", "hello")
agrep(" ", "hello")
agrep(NA, "hello")
agrep(NULL, "hello")
## > agrep("", "hello")
## Error in agrep("", "hello") :
## 'pattern' must be a non-empty character string
## > agrep(" ", "hello")
## [1] 1
## > agrep(NA, "hello")
## [1] NA
## > agrep(NULL, "hello")
## Error in agrep(NULL, "hello") : invalid 'pattern' argument
So I'm guessing you got a ""
in Database`. To check use:
which(Database1 == "")
EDIT:
Use:
rapply(as.list(Database1), function(x) {
try(agrep(x,Database2, max.distance=c(cost=1), value=T))
)
This will tell you where the errors are and then you can hone in on that element and figure out what's causing it. I'd try on multiple subsets of the data.