Reputation: 563
I want to test whether one file exist on gitub, file.exists() is not working:
t= "https://raw.githubusercontent.com/jcolomb/HCS_data_1/master/Project_exampledata1/Routputs/Min_permutated_1.csv"
file.exists(t)
#FALSE
read.csv2(t) #that does work
I tried also:
data = try(read.csv2(paste0(onlinemin,'/Min_',Name_project,'.csv'),dec = ".")
,T)
but then exists("data") is true even when try() is not successful.
any idea?
Upvotes: 0
Views: 306
Reputation: 563
Since I did not want to use another package, I finally used
data = try(read.csv2(paste0(onlinemin,'/Min_',Name_project,'.csv'),dec = ".")
,T)
if (class(data)=="try-error") ...
not very elegant, but works.
Upvotes: 0
Reputation: 996
I think url.exists(t)
from RCurl
library can be what you need.
I hope it helps!
Upvotes: 2
Reputation: 440
require(RCurl)
url_handle<-getCurlHandle()
t= "https://raw.githubusercontent.com/jcolomb/HCS_data_1/master/Project_exampledata1/Routputs/Min_permutated_1.csv"
getURL(t,header=1,nobody=1, curl = url_handle)
getCurlInfo(url_handle,"response.code")
404 means no good. 200 means good to go. You might be able to merge it all to one single line. Happy coding.
Upvotes: 2