[R] ReadLines question
Roger Bivand
Roger.Bivand at nhh.no
Sat Oct 21 23:59:24 CEST 2006
On 21 Oct 2006, Peter Dalgaard wrote:
> 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")
>
Yes, thanks:
read.csv(file("tmp/Marlette_lake_snotel.csv", encoding="iso-8859-1"),
skip=1, check.names=FALSE)
gives usable results on Linux/en_GB and Win/Norwegian (Bokmål) 1252.
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-help
mailing list