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

Michael comtech.usa at gmail.com
Sat Dec 3 02:38:38 CET 2011

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:

[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?

Thanks a lot!

More information about the R-help mailing list