Ezra
Ezra

Reputation: 169

Debugging in R: At which position of list did the function fail?

I have four lists and a very long self-written function. length(list) is over 40.000.

An error occurs when running the function over the lists. I know how to repair the function, but I need to know at which position of the list list[[x]]==? the error occured, so I know which parameters went into the function.

Is there a call to find that out?

Upvotes: 2

Views: 63

Answers (1)

LyzandeR
LyzandeR

Reputation: 37879

You can use recover in the options, i.e. run the following:

options(error = recover)

just before running your function over the list.

This will open the debugger just when the error occurs. Therefore, you can access the environment in that exact iteration (and get access to all objects / arguments) and see what went wrong.

Upvotes: 3

Related Questions