[R] read.csv fails in R console in Ubuntu terminal but works in RStudio after R 3.6.3 upgrade to R 4.0.2?

Daniel Nordlund djnord|und @end|ng |rom gm@||@com
Thu Jul 16 21:26:21 CEST 2020


On 7/15/2020 4:02 PM, Rui Barradas wrote:
> Hello,
>
> R 4.0.2 on Ubuntu 20.04 LTS, sessionInfo below.
>
> I'm also unable to read the file with Rscript from the Ubuntu terminal 
> but the error is not the same as the OP's.
>
>
> The first try was a file test1.R with the following commands.
>
> x<-"https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download" 
>
> read.csv(x, as.is=TRUE, na="n/a")
>
>
> And run with Rscript
>
> rui using rui:~$ Rscript --vanilla test1.R
> Error in file(file, "rt") :
>   cannot open the connection to 
> 'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download'
> Calls: read.csv -> read.table -> file
> In addition: Warning message:
> In file(file, "rt") :
>   cannot open URL 
> 'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download': 
> HTTP status was '403 Forbidden'
> Execution halted
>
>
>
> The second try was download.file() and then read it.
> File test2.R is:
>
> x<-"https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download" 
>
> download.file(x, "companylist.csv")
> read.csv("companylist.csv", as.is=TRUE, na="n/a")
>
>
> But this too failed with error 403 Forbiden.
>
> rui using rui:~$ Rscript --vanilla test2.R
> trying URL 
> 'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download'
> Error in download.file(x, "companylist.csv") :
>   cannot open URL 
> 'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download'
> In addition: Warning message:
> In download.file(x, "companylist.csv") :
>   cannot open URL 
> 'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download': 
> HTTP status was '403 Forbidden'
> Execution halted
>
>
> <<<snip>>>
> ______________________________________________
> 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 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Works fine in Windows 10 64-bit with R-4.0.2, so I would echo Bert 
Gunter's advise to try r-sig-debian list.

Dan

-- 
Daniel Nordlund
Port Townsend, WA  USA



More information about the R-help mailing list