Would it be better to replace all the try statements with tryCatch, because we can assign return values like NA in case of error?
So, for example in boot_networklevel_once(), instead of having this:
for (i in 1:length(ids_lst)){
metric_lst[[i]] <- try({
web <- data[ids_lst[[i]], table(get(col_lower), get(col_higher))]
set.seed(42)
bipartite::networklevel(web = web, index = index, level = level, ...)
})
}
we could better have this:
for (i in 1:length(ids_lst)){
metric_lst[[i]] <- tryCatch({
web <- data[ids_lst[[i]], table(get(col_lower), get(col_higher))]
set.seed(42)
bipartite::networklevel(web = web, index = index, level = level, ...)
},
error = function(e) NA)
}
This will return NA-s in case of errors, though it might be dangerous because try can be still informative because it can return the error message ...
Though tryCatch can also be 'instructed' to pass the error message, but is just getting more verbose than try in that case.
Would it be better to replace all the
trystatements withtryCatch, because we can assign return values likeNAin case of error?So, for example in
boot_networklevel_once(), instead of having this:we could better have this:
This will return NA-s in case of errors, though it might be dangerous because
trycan be still informative because it can return the error message ...Though
tryCatchcan also be 'instructed' to pass the error message, but is just getting more verbose thantryin that case.