I've created an R markdown file that starts by loading a file from the web. I found the cache=TRUE to be a little flaky so I want to put an if condition in to check for the downloaded file before downloading it.
Current Code - Always downloads file
fileURL <- "https://dl.dropbox.com/u/7710864/courseraPublic/samsungData.rda"
setInternet2(TRUE)
download.file(fileURL ,destfile="./data/samsungData.rda",method="auto")
load("./data/samsungData.rda")
Desired Code - only upload if not already downloaded
destfile="./data/samsungData.rda"
fileURL <-
"https://dl.dropbox.com/u/7710864/courseraPublic/samsungData.rda"
if (destFile doesNotExist) {
setInternet2(TRUE)
download.file(fileURL ,destfile,method="auto") }
load("./data/samsungData.rda")
}
load(destfile)
What syntax will give me the condition "destFile doesNotExist"