[R] no line number from error
ross at biostat.ucsf.edu
Fri Apr 25 01:34:37 CEST 2014
On Thu, 2014-04-24 at 19:29 -0400, Duncan Murdoch wrote:
> 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)
> >  "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?
totalEffect is sourced; by "driver" I meant the surrounding code that
sets up dsim and simjob and calls totalEffect.
> 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).
I'm not in a package.
BTW, I encountered several more instances of the error--that is, from
different spots in the code--and never got a line number.
> > 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