[Rd] Strange interaction of browser() and warnings

Rich Calaway richcalaway at revolution-computing.com
Tue Sep 1 02:18:47 CEST 2009


Hi, DevelopeRs,

Consider the following simple function:

myFun <- function(){
	print(log(-1))
	browser()
	print("Bye!")
}

With default settings (in particular, options(warn=0)), if you call this
function and then type only standard browser commands (cont, n, where Q) at
the browser prompt, you see the warning message from printing log(-1)
printed after the final "Bye!":

> myFun()
[1] NaN
Called from: myFun()
Browse[1]> c
[1] "Bye!"
Warning message:
In log(-1) : NaNs produced

However, if you type an ordinary R expression at the browser prompt, you see
the warning message after that expression's output, while still at the
browser prompt:


> myFun()
[1] NaN
Called from: myFun()
Browse[1]> print(2)
[1] 2
Warning message:
In log(-1) : NaNs produced
Browse[1]>

This looks like a bug to me, but admit that I just might not understand
what's going on. So, is it a bug?





Rich Calaway
Documentation Manager
REvolution Computing, Inc.
richcalaway at revolution-computing.com
206-577-4778 x3204



More information about the R-devel mailing list