Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing a .csv into R with UTF-8 encoding error?

I have a .csv file which is written in spanish so it has special characters like ñ, á, é, í, ó, ú. So if I open it in the notepad I can see all the characters properly written and I have already saved the file with UTF-8 encoding. However, when I open RStudio and I import the data using:

servutf <- read.csv("servutf.csv", sep=";")

I get all the dataset but incorrectly encoded i.e.:

Tengo 7 años de experiencia

It should be the following:

Tengo 7 años de experiencia

I have tried everything, I don't know what else to do as I have already checked that R is using UTF-8 encoding and the file is encoded in the same way.

Any suggestion please?

like image 824
adrian1121 Avatar asked Apr 27 '16 13:04

adrian1121


1 Answers

You need to specify the encoding

servutf <- read.csv("servutf.csv", sep=";", encoding = "UTF-8")
like image 104
Thierry Avatar answered Sep 19 '22 14:09

Thierry