Show matched and unmatched results from vector in data table

I suspect that you meant to have those arguments playing opposite roles:

> match(df$Letter, c("A", "R"))
[1]  1  2 NA NA

match looks up its first argument in its second, so generally if you're adding a column to a table, some other column from that table will be passed as the first arg.

By the way, you might want to look at FAQ: How to make your code look nice? Markdown Formatting

3 Likes