When you say options(error = recover)
you are stopping everything to have access to the entire call stack. If you had a function that would have a longer rout, this would be more apparent. In your case, when you enter 1, you go into the function foo
at the time of evaluation. This function holds an object called x
with the values of "foo"
as demonstrated below.
> foo()
Error in foo() : foo
Enter a frame number, or 0 to exit
1: foo()
Selection: 1
Called from: top level
Browse[1]> ls()
[1] "x"
Browse[1]> x
[1] "foo"
If you're done browsing in the current call (in your case under number 1), you can exit to the "menu" by pressing enter or calling c
(see ?browser
).
EDIT
Here's a bit longer example that may show you what recover
does (basically a menu giving you access to called functions and their objects).
> foo <- function(x) {
+ obj1 <- "object in foo"
+ foo2 <- function(y) {
+ obj2 <- "object in foo2"
+ stop()
+ }
+ foo2(x)
+ }
>
> foo(letters)
Error in foo2(x) :
Enter a frame number, or 0 to exit
1: foo(letters)
2: #7: foo2(x)
Selection: 1 # go into function foo()
Called from: top level
Browse[1]> ls()
[1] "foo2" "obj1" "x"
Browse[1]> obj1
[1] "object in foo"
Browse[1]> # i hit enter here
Enter a frame number, or 0 to exit
1: foo(letters)
2: #7: foo2(x)
Selection: 2 # go into function foo2()
Called from: foo(letters)
Browse[1]> ls()
[1] "obj2" "y"
Browse[1]> obj2
[1] "object in foo2"