Sometimes it’s necessary to convert accented characters to non accented in R or Power BI for text analysis purposes. Accented characters might be a problem in texts with spelling mistakes and spoil the analysis.
Convert accented characters in R
Luckily in R is a base function iconv that makes this task easy. You only have to adjust the target encoding.
iconv("schön, natürlich", to = 'ASCII//TRANSLIT') iconv("tā ir dzīve", to = 'Latin1')
If you want to know how useful RStudio tips and tricks, take a look at this post.
Convert accented characters in Power BI (Power Query)
First of all, R should be installed on your workstation.
Open Power Query editor, go to the Transform tab and choose Run R script.
Use the iconv function to convert the dataset column with accented characters. It worked only if the current encoding parameter (from) was defined.
# 'dataset' holds the input data for this script dataset$text <- iconv(dataset$text, from = 'UTF-8', to = 'ASCII//TRANSLIT') output <- dataset
Here is the result.
Here is another example of how to run R script in Power Query.