[R] Help Read File With Odd Characters

Lee Hachadoorian Lee.Hachadoorian+L at gmail.com
Thu Nov 8 23:13:43 CET 2012


On 11/08/2012 02:51 AM, Prof Brian Ripley wrote:
> On 08/11/2012 07:11, Lee Hachadoorian wrote:
>> I have a large (105MB) data file, tab-delimited with a header. There are
>> some odd characters at the beginning of the file that are preventing it
>> from being read by R.
>>
> That is a BOM make in UCS-2 encoding.  Was this file created on Windows?
>
> It so try using iconv to convert it to UTF-8, or in R use
>
> read.delim(filename, fileEncoding = "UCS-2LE")

Perfect. I tried it both ways, and both iconv and the fileEncoding 
parameter did the trick.

As far as I know the file (which was provided by a public agency) was 
created in Windows.

Thanks,
--Lee

-- 
Lee Hachadoorian
Assistant Professor in Geography, Dartmouth College
http://freecity.commons.gc.cuny.edu




More information about the R-help mailing list