pmatch(x, table, nomatch=NA, duplicates.ok=F)
The charmatch function is a close synonym of pmatch. See the documentation for charmatch for a comparison of their differences.
pmatch("Ala",state.name) # is NA (could match Alaska or Alabama) pmatch("Alab",state.name) # is 1, matching Alabama# given names, possibly truncated versions of state names # produce the full state names state.name[pmatch(names,state.name)]