[R] match multiple records

Weiwei Shi helprhelp at gmail.com
Tue Jun 21 00:34:48 CEST 2005


Hi,

I have a question, explained by the following example:
> a<-c(1,2,3)
> b<-c(1,1,2,4)
> b[match(a,b, nomatch=0)]
[1] 1 2

which means it returns "the first match", but I want to get
1 1 2 instead of 1 2

In a word, how to do multiple matching?

thanks,

-- 
Weiwei Shi, Ph.D

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III




More information about the R-help mailing list