[R] Help! Big problem when using "browser()" to do R debugging?

Duncan Murdoch murdoch.duncan at gmail.com
Sat Dec 3 02:43:59 CET 2011


On 11-12-02 8:38 PM, Michael wrote:
> Hi all,
>
> Could you please help me?
>
> I am having the following weird problem when debugging R programs
> using "browser()":
>
> In my function, I've inserted a "browser()" in front of Step 1. My
> function has 3 steps and at the end of each step, it will print out
> the message "Step i is done"...
>
> However, after I hit<ENTER>  when the program stopped before Step 1
> and entered into the debugging mode, it not only executed the next
> line(i.e. the Step 1), but also all the (many) remaining lines in that
> function, as shown below:
>
>
> Browse[1]>
> [1] "Step 1 is done.."
> [1] "Step 2 is done.."
> [1] "Step 3 is done.."
>
> Then it automatically quited the debugging mode and when I tried to
> check the value of "myobj", I've got the following error message:
>
>> names(myobj)
> Error: object 'myobj' not found
> No suitable frames for recover()
>
> ----------------------------------------------------
>
> So my question is: why did one key stroke<ENTER>  lead it to execute
> all the remaining lines in that function and then "returned" from the
> function and quited the debugging mode?

See ?browser.

Duncan Murdoch



More information about the R-help mailing list