I am interested in applying the levenshteinSim
function from the Record-Linkage package to vectors of strings (there's a good discussion on the function here ).
Imagine that I have a vector called codes
: "A","B","C","D"
,etc.;
And a vector called tests
: "A","B","C","D"
,etc.
Using sapply
to test a particular value in 'tests' against the vector of codes
,
sapply(codes,levenshteinSim,str2=tests[1])
I would expect to get a list or vector (my apologies if I make terminological mistakes): [score1] [score2] [score3]
.
Unfortunately, the output is a test of the value in tests[1]
against c("A","B","C","D", ...)
-- a single value.
Ultimately, I want to *apply
the two vectors against one another to produce a matrix of length len1*len2
-- but I don't want to move forward until I understand what I'm doing wrong.
Can anyone provide guidance?