[R] ReadLines question

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sat Oct 21 22:24:59 CEST 2006

Roger Bivand <Roger.Bivand at nhh.no> writes:

> On Sat, 21 Oct 2006, Jonathan Greenberg wrote:
> > That looks to me like an infinity sign (I have no idea why that is part of
> > the header of this file, but it is there).  How do I modify the encoding to
> > read this in? 
> The problem is the degree sign. Under linux:
> $ file tmp/Marlette_lake_snotel.csv
> tmp/Marlette_lake_snotel.csv: ISO-8859 text, with CRLF, CR line terminators
> so probably the conversion to multibyte is happening on your reading 
> platform. Reading the file into 2.4.0 on Windows with a Norwegian 1252 
> setting (Sys.getlocale()), I see the degree sign.

Nono, there is no conversion. R is _expecting_ a multibyte sequence
(utf8 most likely) and finding something that isn't part of one.  

The fix should be something close to

read.csv(file("tmp/Marlette_lake_snotel.csv"), encoding="iso-8859-1") 

   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907

More information about the R-help mailing list