tell the error function what to return :
tryCatch({
data <- GetRemoteData(source = "Montel",
requestType = "trade",
fromDate = today,
toDate = "",
v.ids = c("EEX DEB WKND0"),
nRetry = 0)
},
error = function(data) {
matrix <- matrix(1:9, nrow = 3, ncol = 3)
matrix
})
If a function is to return a value, that value should be the last thing before exiting the function, your error function assigned a matrix to a variable 'matrix' but then didnt return it. Naming it, doesnt seem worthwhile so better code might be
tryCatch({
data <- GetRemoteData(source = "Montel",
requestType = "trade",
fromDate = today,
toDate = "",
v.ids = c("EEX DEB WKND0"),
nRetry = 0)
},
error = function(data) {
matrix(1:9, nrow = 3, ncol = 3)
})