I need a function in R to "clean" accents from a string. I was using the accepted solution from
https://stackoverflow.com/a/20495866/7396118
I created an external function, included the algorithm proposed by @Thomas, and saved in a function clean.r. So when i called clean("ááb"), the result was "aab".
This worked just fine for a long time, but now, all of a sudden, it stoped working. When I try to call the function, I get the following message: Error in chartr(old, new, x) : 'old' is longer than 'new'.
When I print each argument from inside my "clean.r" function, they look like:
print(old) > "ÀÃ\u0081ÂÃà ..."
print(new) > "AAAAA..."
So, they are indeed different. When I call the function, it does not understand the correct encoding for the characters with accent. When I open the clean.r file and run the code line by line, it works fine, but when I call it from within another function, it doesn't work. I'm importing it as source("clean.r")
Does anyone know how can I deal with that? Is there a simpler way to exclude accents from a string?
Thanks a lot.