Why is pmatch() not working for my vectors

I have two vectors.

First one is:

x
 [1] "    scharfkantig"   "t"                  " aht  36 üz distal" " seit paartagen"   
 [5] "36 vipr"            " perk "             "üz bilfuird"        " "                 
 [9] ""                   " knirscht"          " schiene empohlen"  "  meldet "         

Second one is:

 y
  [1] "01"                                  "beobachten"                         
  [3] "hkp"                                 "hkp"                                
  [5] "abform kiefer"                       "abform bissfix"                     
  [7] "opt elek abform"                     "vipr"                               
  [9] "perk"                                "oberfl anästh"                      
 [11] "anästh"                              "vest inj"                           
 [13] "inj sept blau"                       "cx pulpennah"                       
 [15] "infiltration"                        "injektion"                          
 [17] "infil"                               "l1"                                 
 [19] "gezeigt zu achten"                   "putzdruck"                          
 [21] "mhu"                                 "gezeigt"                            
 [23] "pat gezeigt"                         "pzr"                                
 [25] "psi sbi api"                         "dentalhygiene"                      
 [27] "duraphat aufge"                      "empfindliche stelle aufgetragen"    
 [29] "üz"                                  "duraphat"

Now I want the index of the elements of the second vector if they partially match with the first vector.
Logically the output should be: (29 8 9)

First of all I used this codes:

which(y %in% x)
match(y, x)
match(y, x)

But this didn`t work.
Now when I try it with:

pmatch(x= y, table = x,  duplicates.ok = TRUE)

I just get

[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA  7 NA

back and I don`t know why. I do everything as it is written in the documentation.

Thank you very much in advance.

pmatch() is matching the start of strings not if the string contains a set of strings.

you should perhaps trimws() the first vector, arbitrary spaces wont ever partial match something that doesnt begin with spaces. I suppose the question is if the 'pmatch' concept of what a partial match is agrees with your requirements to partial match.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.