[R] Debugging a hanging function within R
Yan Wong
h.y.wong at leeds.ac.uk
Fri Nov 16 15:48:58 CET 2007
On 16 Nov 2007, at 14:16, Duncan Murdoch wrote:
> On 11/16/2007 6:58 AM, Yan Wong wrote:
>> Hi,
>> I can't seem to find a way to do this (i.e. interrupt a routine at
>> an arbitrary time during its run, then step into it using the
>> debugger).
>
> If you prepare in advance by using options(error=recover), it's easy:
>
> > options(error=recover)
> > f <- function() {
> + i <- 0
> + repeat {
> + i <- i + 1
> + x <- rnorm(10000)
> + }
> + }
> > f()
>
> # At this point, R appears hung up. I hit Esc in the Windows
> Rgui. In Unix or Rterm, you'd use Ctrl-C.
That's exactly what I wanted. Thank you. I didn't realise that
sending an interrupt signal was treated as a "normal" error.
Out of interest, is there any way to resume the routine from where it
was interrupted (and ideally do so in debugger mode, so I can step
through the lines of the code)?
Thanks again
Yan
More information about the R-help
mailing list