2

I am quite a newbie to R and currently struggling with CSV importing. I am trying to import a large CSV table with accented characters in Italian (such as è,é,ì), but am failing to code it properly.

The command I first tried was:

comuni_giornaliero_dati_fino_31agosto <- read.csv("directory_here", header=FALSE, comment.char="#")

And what I got were messed up accents, e.g.

Agli<e8>

instead of "Agliè"

Mondov<ec>

instead of "Mondovì" etc.

So I tried and guessed the encoding:

guess_encoding("directory_here",n_max=100,threshold = 0.2)

A tibble: 1 x 2 encoding confidence 1 ISO-8859-1 0.47

So I tried specifying the encoding:

comuni_giornaliero_dati_fino_31agosto <- read.csv("directory_here", header=FALSE, comment.char="#",encoding = "ISO-8859-1")

But I still can't have RStudio properly read accents. Any guesses? Feels like an easy task but I am too unfamiliar with R to sort this out.

Thanks in advance!

Elia
  • 21
  • 2
  • 1
    Just guessing, using `read.csv("directory_here", header=FALSE, comment.char="#",fileEncoding = "ISO-8859-1")` (i.e. `fileEncoding` instead of `encoding`) might work. If not, please add the result of `sessionInfo()` to your post. – user2554330 Nov 30 '20 at 14:04
  • @user2554330 thank you, it solved the issue! Still struggling to grapple with the logic but it works. – Elia Nov 30 '20 at 14:36

0 Answers0