[R] partial match for two datasets

Lynn Wang
2009-12-09T01:46:22Z

Hi all,

I have two sets:

dig<-c("DAVID ADAMS","PIERS AKERMAN","SHERYLE
BAGWELL","JULIAN BAJKOWSKI","CANDIDA BAKER")

import<-c("by DAVID ADAMS","piersAKERMAN","SHERYLE
BagWEL","JULIAN BAJKOWSKI with ","Cand
BAKER","smith green")


I want to get the following result from "import" after comparing the
two sets

result<-c("by DAVID ADAMS","piersAKERMAN","JULIAN
BAJKOWSKI with ")


I created a "partialmatch" function as follow, but can not get right
result.

partialmatch<- function(x, y) as.vector(y[regexpr(as.character(x),
as.character(y), ignore.case = TRUE)>0])

result<-partialmatch(dig,import)


[1] "by DAVID ADAMS"



Thanks,

lynn



__________________________________________________________________________________
Win 1 of 4 Sony home entertainment packs thanks to Yahoo!7.
Enter now: http://au.docs.yahoo.com/homepageset/
	[[alternative HTML version deleted]]