[R] Matching Problem

Newbie19_02 nvanzuydam at gmail.com
Tue Feb 23 13:34:55 CET 2010


I have a problem with function match.  I might not be using it properly?

I have two character vectors that contain a unique identifier:

gtype_prochi <- ("CAO1524452" "CAO0966182" "CAO9209719" "CAO4436178"
"CAO3529266" "CAO2427148" "CAO8829776" "CAO2517174" "CAO5371418"
"CAO1535943" "CAO1782827" "CAO5048528" "CAO3355531" "CAO6972025"
"CAO5424346" "CAO2487177" "CAO6958863" "CAO4966402" "CAO1542471"
"CAO3651581" "CAO8066673" "CAO7038589" "CAO9396088" "CAO3970255"
"CAO9748084" "CAO0134895" "CAO4402488" "CAO2611552" "CAO5076137"
"CAO6765658" "CAO5210145" "CAO7322401" "CAO3123811" "CAO3866028"
"CAO8481324" "CAO2046484" "CAO1461245" "CAO0421700" "CAO4584012"
"CAO0194083" "CAO2395689" "CAO9560781" "CAO3950951" "CAO7950101"
"CAO5175707" "CAO4392323" "CAO9684919" "CAO8919826" "CAO6685513") 


merge_prochi <-  ("CAO0001743" "CAO0003129" "CAO0004563" "CAO0018045"
"CAO0034275" "CAO0039712" "CAO0045125" "CAO0048575" "CAO0055131"
"CAO0056636" "CAO0075804" "CAO0076632" "CAO0083069" "CAO0103166"
"CAO0109559" "CAO0113512" "CAO0114087" "CAO0122832" "CAO0143034"
"CAO0153344" "CAO0164033" "CAO0167974" "CAO0172899" "CAO0182089"
"CAO0183227" "CAO0200685" "CAO0212229" "CAO0226616" "CAO0236387"
"CAO0241649" "CAO0242493" "CAO0251018" "CAO0253877" "CAO0259290"
"CAO0261913" "CAO0263615" "CAO0267251" "CAO0279172" "CAO0279713"
"CAO0286825" "CAO0287077" "CAO0295190" "CAO0312448" "CAO0319405"
"CAO0337134" "CAO0347741" "CAO0367128" "CAO0374110" "CAO0374779")

I have used the following:

test_match <- match(merge_prochi, gtype_prochi, nomatch=0,

test_match <- (1620 3161   NA 2191 1957   NA  422 1040 1031   NA   NA   NA  
NA   NA   NA
 NA 1956   NA   NA   NA   NA   NA   NA  586   NA   NA  182   NA 3234   NA
NA   NA   NA   NA   NA   NA 3075  556 1794 1451   NA 1991 1791   NA  992
1424   NA  764   NA   NA)

is the ouput.  What I'm trying to do is compare two columns between two data
frames to look for common prochi numbers.  I then want to use these common
prochi numbers to subset another data frame.  I'm not sure if I am using the
correct thing or doing it the right way.


View this message in context: http://n4.nabble.com/Matching-Problem-tp1565841p1565841.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list