4

this was expected to be much easier but I cannot get it done in R. I have a very simple file which contains some information stored as strings. There is also a currency tab, which contains characters like "$" or "£".

I use the following to import the file, wich works fine:

x <- read.csv("C:/file_information.csv", sep = ";", stringsAsFactors = F, 
              row.names = 1, header = F)

The file has a structure like this (it contains also NAs):

matrix(c("A","B","","","£", "$","D","E","C"),3,3)

How can I import this file correctly? I tried to play around with the fileEncoding option, but could not get it done.

The csv was originally created from excel 2013 (comma delimited csv).

Surprisingly dollar signs are displayed correctly but for pound signs there is a question mark in a black square instead.

user3032689
  • 627
  • 1
  • 10
  • 23
  • Which encoding is used for the CSV file? How have you tried to load it with the appropriate encoding? –  Jun 18 '16 at 13:35
  • Its the default: Westeuropean(Windows). I cannot choose this in R, can I? Edit: I read somewhere the correct name for it is 'excel ANSI encoding', – user3032689 Jun 18 '16 at 13:38
  • Sure you can. You just have to know the *formal* name of the encoding (in this case, it's either ISO-8895-1, or Microsoft's superset of it, Windows-1252), and then that that encoding is called `latin1` in R. Then, your question should be a duplicate of [this question](http://stackoverflow.com/questions/14363085/invalid-multibyte-string-in-read-csv). –  Jun 18 '16 at 13:42
  • 2
    Sorry my bad. It actually did fix the problem. When I print the table on the console it displays correctly. It only didn't display correctly when I clicked on the table on the right hand side of R Studio in order to generate the preview. Seems to be an issue with the file previewer then. Thank you! – user3032689 Jun 18 '16 at 13:55

0 Answers0