What I'm trying to do is load a data file from a local directory. If it is not there, download it from the web server. I am currently using a nested tryCatch and it seems to work. Is this an attempt to complete this task in R?
tryCatch(
{
assign("installations", read.csv('data.csv'), envir=.GlobalEnv)
print("Loaded installation data from local storage")
},
warning = function( w )
{
print()
},
error = function( err )
{
print("Could not read data from current directory, attempting download...")
tryCatch(
{
assign("installations", read.csv('http://somewhere/data.csv'), envir=.GlobalEnv)
print("Loaded installation data from website")
},
warning = function( w )
{
print()
},
error = function( err )
{
print("Could not load training data from website!! Exiting Program")
})
})
source
share