Search code examples
rmclapply

List all the indices that has a error message in a nested list R


I am using mclapply to run my code in parallel. Below is a snippet of my code. When I set mc.preschedule = FALSE, it stores the error and goes to next item in the list. I want to see what all the elements in the list has a associated error message.

OutputList = mclapply(Users.list,TestFunction,mc.cores = 25,mc.preschedule = FALSE)

Below is the error message for one of the item in a list.

`Jack`
[1] "Error in TestFunction(DF, x) : \n  Nodes in query cannot be found in the input graph.\n\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in TestFunction(DF, x): Nodes in query cannot be found in the input graph.

Is there a way I can list all the indices that contains any error message?


Solution

  • which(mapply(inherits, OutputList, 'try-error'))