[R] no line number from error

Duncan Murdoch murdoch.duncan at gmail.com
Fri Apr 25 01:29:55 CEST 2014


On 24/04/2014, 6:40 PM, Ross Boylan wrote:
>   > r1 <- totalEffect.all(dsim, simjob)
>   Error: attempt to apply non-function
>   > traceback()
>   1: totalEffect.all(dsim, simjob)
>   > class(totalEffect.all)
>   [1] "function"
> How can I find out where in totalEffect.all the error is arising?
> My only theory for the lack of line number was that totaEffect.all was
> not a function; it is.  Further, previous calls to the function worked,
> and errors in it produced line numbers.  After fixing a previous error
> I'm now getting this.
>
> All my code is sourced from files except for the driver.  The driver
> code is in the same file that defines totalEffect.all.

I don't understand this.  If totalEffect.all is in a file that is not 
sourced, where did it come from?

Generally the rule is that if you source a function from a file you'll 
get line number information attached to it, so you should see a line 
number reported when an error occurs, or during debugging.  There are 
exceptions:  you can turn this off, and by default, it is turned off for 
functions defined in packages (but you can turn it on if you re-install 
from source).

>
> In this particular case I stepped through with the debugger and found
> that in the  line
> accums[[m]]$delta$accum(up - down, data)
>
> the delta object was NULL and so accum is not a function on it.  But I
> hope there's a better way to locate an error.

If the line that triggered this error was in a function that had line 
number information, it sounds like it might be a bug.  Can you simplify 
it down to a simple reproducible example that I could look at?

Duncan Murdoch




More information about the R-help mailing list