[R] find duplicates... need help!

njhuang86 njhuang86 at yahoo.com
Tue Jul 7 21:28:41 CEST 2009


Hi all,
Suppose I have x = c('a', 't', 'c', 'y', 'g')
and also y = c('a', 'a', 'g', 's')

If I do something like x%in%y, I obtain a vector like this: [TRUE, FALSE,
FALSE, FALSE, TRUE] which I can easily turn into this: [1, 0, 0, 0, 1].
I was wondering is there anyway for me to get a vector back in return in the
form of: [2, 0, 0, 0, 1]? Essentially, the 2 will tell me that in the first
position of vector 'x', there were two matches found with vector y.

Thanks a ton in advance!
-- 
View this message in context: http://www.nabble.com/find-duplicates...-need-help%21-tp24379828p24379828.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list