[R-SIG-Mac] Encoding issue with read.csv
stefan.evert at uos.de
Sat Oct 24 21:01:48 CEST 2009
>> I've been given a CSV file saved on an old Windows 2000 machine. I
>> think it's coded in Windows-1252 (roughly equivalent to ISO-8859-1 I
>> When I try to open it with read.csv('foo.csv', encoding =
>> 'iso-8859-1') I get a coding error.
>> However, if I do:
>> options(encoding = 'iso-8859-1')
>> data <- read.csv('foo.csv')
>> The file is opened smoothly. What am I doing wrong? Shouldn't the
>> first work if the second does?
Perhaps you meant to use fileEncoding="iso-8859-1" instead of
encoding="iso-8859-1"? Because that does the same as setting
options(encoding="iso-8859-1") -- see ?read.table for details.
While you're at it, why not try fileEncoding="cp1252", which should
read Windows-1252 correctly (even the non-Latin1 characters)? You
should make sure that your R is running in a Unicode locale, otherwise
it might complain because the Windows-specific characters cannot be
represented in its native character set.
[ stefan.evert at uos.de | http://purl.org/stefan.evert ]
More information about the R-SIG-Mac