I'm using RSelenium and lapply() to scrape a fairly complex set of pages. I occasionally run into problems with the page not loading as expected and thus the code failing.
It happens so rarely that rather than try and deal with every possible error, I would just like to skip the current iteration and go on to the next. It looks like tryCatch() is what I'm looking for, but I'm not sure where to put it in the code.
I know this is not complete but I hope this is enough to go on as it looks like tryCatch() is wrapped around lapply() or with the return() statement. Thanks in advance.
team_id <- c(1:10)
df_list <- lapply (1:length(team_id), function(x) {
# complex navigation and scraping of multiple sub tables
# to create a final teamtable
<code>
return(teamtable)
})
df <- data.table::rbindlist(df_list)
return(teamtable), error = function(e) return(NULL))`? I'm gettig a _expected ',' after expression_ warning throughout my
– seansteele Jul 31 '20 at 01:14.
` in `{}`. See update in the answer.
– Ronak Shah Jul 31 '20 at 01:27