Skip to content
Prev 312633 / 398506 Next

Line numbers with errors and warnings?

On 12-12-02 12:31 AM, Worik R wrote:
I think ESS is not a distraction here, it is the cause of the problem. 
If you source() your code, R will (by default) record line numbers.  ESS 
apparently doesn't send code to R using source().  (Or perhaps it does, 
and you aren't looking in the right place for it?)

For example, in Windows, if I put this code into the clipboard:

f <- function() {
   stop("this is the error")
}

g <- function() {
   f()
}

g()

then run source("clipboard") followed by traceback(), this is what I see:

 > source("clipboard")
Error in f() (from clipboard#2) : this is the error
 > traceback()
7: stop("this is the error") at clipboard#2
6: f() at clipboard#6
5: g() at clipboard#9
4: eval(expr, envir, enclos)
3: eval(ei, envir)
2: withVisible(eval(ei, envir))
1: source("clipboard")

You can ignore entries 1 to 4; they are part of source().  Entries 5, 6, 
and 7 each tell the line of the script where they were parsed.

Duncan Murdoch