I have two vectors, one with 387 codes and another with 3,000 occurrences of one or more of these 387 codes. I need to know how many times each of these 387 codes occurred in this vector of 3,000 occurrences. I've done it with "for" loops and it worked, but the execution time is gigantic. I tried using the "table" command but it did not work. I saw a suggestion from daniel but it creates a data-frame with two variables (ok) but with the same number of lines, which is not my case.