Assigning correct case to names using R

56 views Asked by At

Hi im currently looking at cleaning peoples names in our of systems to ensure they all look uniform though the system. The aim would be to ensure the first letter is upper the remaining lower.You can use str_to_title in R the problem however is when you have names like McDonald etc then the function will only set the M as title and not the D. I need to first detect which names need cleaning so you not attempting clean items that don't need cleaning. You could probably do that using a regex such as str_detect(name,pattern=^[A-Z]\D+)==FALSE which will work in most cases except the example i have detailed below. Then secondly to case the names correctly.Does anyone know of any packages you can use to properly case names or would i need to create a custom function to do this and how would I achieve it?

Have used str_to_title function in R to correct name casing which is correct in most case for the exception of the name starting with Mc or any other names that share a similar rule that require this type of casing.

0

There are 0 answers