STAT547-UBC-2019-20 / group05

Repository for our team project (group 05)
0 stars 3 forks source link

Can't run script from terminal #18

Closed iciarfernandez closed 4 years ago

iciarfernandez commented 4 years ago

Hi @yuliaUU @firasm, I'm trying to run my load.R script (which I need to run the rest of the scripts in the project) by writing the following code on my terminal:

rscript load.R 'https://ndownloader.figshare.com/files/18543320?private_link=74a5ea79d76ad66a8af8'

But I get this error:

Error in download.file(url = url_to_read, destfile = (here::here("data",  :
scheme not supported in URL 'https://ndownloader.figshare.com/files/18543320?private_link=74a5ea79d76ad66a8af8'
Calls: main -> download.file
Execution halted

I have checked that I have all the packages required for the script to run, tried writing the url in the terminal with "", with '', and without quotes at all, and it's just not working whatever I do. It's not giving me any other errors either. Please let me know what to do.

Thanks, Icíar

yuliaUU commented 4 years ago

@sciclic I ran the script, and it works perfectly for me: can you give me the following info: if you run the code in terminal cd what is the directory your are in?

firasm commented 4 years ago

@sciclic 2 things:

1) are you on Windows ?

2) try changing the url so it's http rather than https

iciarfernandez commented 4 years ago

Hello again,

@yuliaUU my cd was "group05/" @firasm, I tried the http thing and it worked! Why is that?

Thanks for your help!

firasm commented 4 years ago

It's a long and complicated story related to how windows deals with files and encodings (I think). It's probably not important and I'm not sure I fully understand it either, but it's kind of summarized here.

In order to robustly deal with binary files (excel) across platforms), I think the better solution is to try one of these two methods from this Stack overflow answer:

url = 'https://ndownloader.figshare.com/files/18543320?private_link=74a5ea79d76ad66a8af8'
raw = curl::curl_fetch_memory(url)$content
read_excel.raw(raw)

Let us know if it works!

Firas