You can use the function gsub
for that. gsub("Ln", "Lane", addresses)
where adresses
is a vector with your adresses as strings, replaces all occurences of "Ln" with "Lane". You can use Regex with this, but I don't think that really helps you.
So all you have to do is call that function for all substitutions you want to make and you're done. R doesn't have dictionaries (as far as I know), so doing it all in once would require another format to store your mappings.
To answer your question on how to do it for multiple dictionary entries:
Since we don't have dictionaries in R, we take the next best thing: lists. List entries have a name and an object (value, vector, anything really). We can make the name of the entry the dictionary key, and the value its translation:
dict <- list(St = "Street",
Rd = "Road",
Ln = "Lane",
Pl = "Place")
Taking the adresses in your example:
Adresses <- c("2/20,Queen St,London,UK",
"1,King Ln,Paris,France",
"5,Stuart Pl,Paris,France")
Now we can loop over the entries of the list, create the expression (using the \b
tags as mentioned by @wibeasley), and replace it with the entry in the list. Each time we overwrite the Adresses vector with the results, so we are sequentially applying all filters.
for(i in 1:length(dict)){
Adresses <- gsub(paste0("\\b", names(dict)[i], "\\b"), dict[[i]], Adresses)
}