Re: [R] Reading a txt file from internet

2024-09-07 Thread Jeff Newmiller via R-help
I tried it on R 4.4.1 on Linux Mint 21.3 just before I posted it, and I just tried it on R 3.4.2 on Ubuntu 16.04 and R 4.3.2 on Windows 11 just now and it works on all of them. I don't have a big-endian machine to test on, but the Unicode spec says to honor the BOM and if there isn't one to ass

Re: [R] Reading a txt file from internet

2024-09-07 Thread Duncan Murdoch
On 2024-09-07 4:52 p.m., Jeff Newmiller via R-help wrote: When you specify LE in the encoding type, you are logically telling the decoder that you know the two-byte pairs are in little-endian order... which could override whatever the byte-order-mark was indicating. If the BOM indicated big-en

Re: [R] Reading a txt file from internet

2024-09-07 Thread Jeff Newmiller via R-help
When you specify LE in the encoding type, you are logically telling the decoder that you know the two-byte pairs are in little-endian order... which could override whatever the byte-order-mark was indicating. If the BOM indicated big-endian then the file decoding would break. If there is a BOM,

Re: [R] Reading a txt file from internet

2024-09-07 Thread Jeff Newmiller via R-help
Add the fileEncoding = "UTF-16" argument to the read call. For a human explanation of why this is going on I recommend [1]. For a more R-related take, try [2]. For reference, I downloaded your file and used the "file" command line program typically available on Linux (and possibly MacOSX)

Re: [R] Reading a txt file from internet

2024-09-07 Thread Bert Gunter
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 t it would have immediately led me to BOMs. Best, Bert On Sat, Sep 7, 2024 at 1:30 PM Iris Simmons wrote:

Re: [R] Reading a txt file from internet

2024-09-07 Thread Enrico Schumann
On Sun, 08 Sep 2024, Christofer Bogaso writes: > 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/f

Re: [R] Reading a txt file from internet

2024-09-07 Thread Iris Simmons
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 wrote: > > Hi, > >

Re: [R] Reading a txt file from internet

2024-09-07 Thread Bert Gunter
Well, this is frankly an unsatisfactory answer, as it does not try to deal properly with the issues that you experienced, which I also did. However, it's simple and works. As this is a small text file, simply copy it in your browser to the clipboard, and then use: thefile <- read.table(text = "", h

[R] Reading a txt file from internet

2024-09-07 Thread Christofer Bogaso
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, un

Re: [R] BUG: atan(1i) / 5 = NaN+Infi ?

2024-09-07 Thread Martin Maechler
> Richard O'Keefe > on Sat, 7 Sep 2024 02:40:29 +1200 writes: > G.5.1 para 2 can be found in the C17 standard -- I > actually have the final draft not the published standard. Ok. Thank you. A direct hopefully stable link to that final draft's Appendix G seems to be h