R: Replace all marked letters with normal letters

I am looking for an easy way to replace all dotted letters with regular letters. For example, I want to change föóto foo. I can do it as such:

gsub("ö|ó","o","föó")

however, there will probably be a lot of manual work to do this for every possible intermittent writing. Is there any way to do this automatically?

+3
source share
1 answer

You can try several options:

    cleanString <- function(x){
        tmp <- iconv(x, from="UTF8", to ="ASCII//TRANSLIT")
        gsub("[^[:alpha:]]", "", tmp)
        }

x = "föó"

cleanString(x)

[1] "foo"

the idea of ​​using iconv from removing diacritics from a string

+9
source

All Articles