R/fuzzy_replace.R
fuzzy_search.Rd
Search for a word or phrase in a second vector that matches the another word in the first vector.
fuzzy_search(x = NULL, y = NULL)
x | The vector with strings to be searched for in the second vector |
---|---|
y | The vector with usually the correct strings to be found |
A vector of best matches from y based on the x input vector.
This is a helpful function to correct city names according to IBGE names, when the list is to long to correct by hand.
wrong_names<-c("Mogi das Cruses","Sao Paulo","CANTA GALLO") correct_names<-c("Canta Galo","Mogi das Cruzes","São Paulo") fuzzy_search(x=wrong_names,y=correct_names)#> [1] "Mogi das Cruzes" "São Paulo" "Canta Galo"