Concatenate gsub

gsub, optimization, r, regex

Solution

Try something like this

iconv(c('Á'), "utf8", "ASCII//TRANSLIT")

You can just add more elements to the `c()`.

EDIT: it is machine dependent, check `help(iconv)`

Here is the `R` solution

mychar <- c('ÁÃÉÊÍÓÕÚÇ')
iconv(mychar, "latin1", "ASCII//TRANSLIT") # one line, as requested
[1] "AAEEIOOUC"

Problem

I'm currently running the following code to clean my data from accent characters: ``` df <- gsub('Á|Ã', 'A', df) df <- gsub('É|Ê', 'E', df) df <- gsub('Í', 'I', df) df <- gsub('Ó|Õ', 'O', df) df <- gsub('Ú', 'U', df) df <- gsub('Ç', 'C', df) ``` However, I would like to do it in just one line (using another function for it would be ok). How can I do this?

Original source

Related problems