[R] agrep: How to match with more than 1 substitution?

Niklaus Kuehnis kuehnik_0505 at gmx-topmail.de
Thu Jun 23 15:59:15 CEST 2011


Hi all

I'm trying to match a numeric code to a vector of numeric codes:

a <- c(12345, 12346, 12347)

agrep(12349, a, max.distance=list(substitutions=1))
# [1] 1 2 3

agrep(12399, a, max.distance=list(substitutions=2))
# integer(0)

I didn't expect the latter result as substituting two characters from 
the pattern makes the pattern identical to the vector elements.

What do I need to change to match with more than 1 substitution allowed?

Thanks in advance,
Nik



More information about the R-help mailing list