AFP_555
AFP_555

Reputation: 2608

RStudio - Weird characters becoming regular characters

I'm working with a messy database, in which I need to give format to some columns of data. For this, I use a lot of GSub and other forms of regular expressions. My problem is some of the characters I need to clean are "weird" characters, specially the A with the curly thing above followed by other weird character (Ñ).

When I copy from the database and then paste on my gsub function:

gsub("CALLÑE", "CALLE", data)

enter image description here

It works fine until I close and RStudio and reopen it. Then the characters are different in the RScript file. It is as if RStudio didn't support weird characters itself, and removes them from the Scripts when they are reopened:

gsub("CALLÃ'E", "CALLE", data)

enter image description here

How can I avoid this? And keep my weird characters even after closing the file.

Upvotes: 0

Views: 821

Answers (1)

Karthik Arumugham
Karthik Arumugham

Reputation: 1360

In RStudio, go to File -> Save with Encoding...

Select UTF-8 option.

Upvotes: 2

Related Questions