TryCatch with Loop

Works nicely thanks!

So the solution to my problem is:

for(i in 1:length(x)) {
  
  tryCatch(
    data <- read.csv(url(paste("the_web_address.com", "_data_", x[i], ".csv", sep=("")))),
    error = function(e){
      data <<- data # use the dataset from the previous iteration which should still be in memory
      print("There was an error")
      data_missing <<- data_missing + 1
    })

# Do useful stuff here
}

Edit: Probably the data <-- data is redundant in that mini-example but in my real example I have to alter the index within the data, so I write something like

data$t = data$t + 1