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

Liviu Andronic landronimirc at gmail.com
Sat Dec 3 09:15:56 CET 2011

On Sat, Dec 3, 2011 at 2:38 AM, Michael <comtech.usa at gmail.com> 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?
As soon as you get into 'debug' mode, type 'n', hit <enter>, then you
can simply hit <enter> to evaluate the fun step by step. To exit the
step-by-step, type 'c' and hit enter: this will evaluate the rest of
the function.


> Thanks a lot!
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Do you know how to read?
Do you know how to write?

More information about the R-help mailing list