[R] Reading a txt file from internet

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Sat Sep 7 22:44:47 CEST 2024


Ha, the proper answer!
Thanks for this, Iris. I followed up by consulting the Wikipedia "byte
order mark" entry and learned something I knew nothing about.

FWIW, if I had simply searched on <ff><fe>t it would have immediately led
me to BOMs.

Best,
Bert

On Sat, Sep 7, 2024 at 1:30 PM Iris Simmons <ikwsimmo using gmail.com> wrote:

> That looks like a UTF-16LE byte order mark. Simply open the connection
> with the proper encoding:
>
> read.delim(
>     '
> https://online.stat.psu.edu/onlinecourses/sites/stat501/files/ch15/employee.txt
> ',
>     fileEncoding = "UTF-16LE"
> )
>
> On Sat, Sep 7, 2024 at 3:57 PM Christofer Bogaso
> <bogaso.christofer using gmail.com> wrote:
> >
> > Hi,
> >
> > I am trying to the data from
> >
> https://online.stat.psu.edu/onlinecourses/sites/stat501/files/ch15/employee.txt
> > without any success. Below is the error I am getting:
> >
> > > read.delim('
> https://online.stat.psu.edu/onlinecourses/sites/stat501/files/ch15/employee.txt
> ')
> >
> > Error in make.names(col.names, unique = TRUE) :
> >
> >   invalid multibyte string at '<ff><fe>t'
> >
> > In addition: Warning messages:
> >
> > 1: In read.table(file = file, header = header, sep = sep, quote =
> quote,  :
> >
> >   line 1 appears to contain embedded nulls
> >
> > 2: In read.table(file = file, header = header, sep = sep, quote =
> quote,  :
> >
> >   line 2 appears to contain embedded nulls
> >
> > 3: In read.table(file = file, header = header, sep = sep, quote =
> quote,  :
> >
> >   line 3 appears to contain embedded nulls
> >
> > 4: In read.table(file = file, header = header, sep = sep, quote =
> quote,  :
> >
> >   line 4 appears to contain embedded nulls
> >
> > 5: In read.table(file = file, header = header, sep = sep, quote =
> quote,  :
> >
> >   line 5 appears to contain embedded nulls
> >
> > Is there any way to read this data directly onto R?
> >
> > Thanks for your time
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> https://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list