How do I check the existence of a downloaded file
Solution 1:
You can use tryCatch
if(!file.exists(destfile)){
res <- tryCatch(download.file(fileURL,
destfile="./data/samsungData.rda",
method="auto"),
error=function(e) 1)
if(dat!=1) load("./data/samsungData.rda")
}
Solution 2:
As per the answer given by @agstudy
destfile="./data/samsungData.rda"
fileURL <-
"https://dl.dropbox.com/u/7710864/courseraPublic/samsungData.rda"
if (!file.exists(destfile)) {
setInternet2(TRUE)
download.file(fileURL ,destfile,method="auto") }
load("./data/samsungData.rda")
}
load(destfile)