I've created a 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 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"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…