Skip to content
Prev 29409 / 63424 Next

methods/namespaces/possible bug

On Jul 15, 2008, at 12:00 PM, Duncan Murdoch wrote:

            
Let me just state that if I do

plot(sin)

plot.function gets called. This looks to me (as a somewhat experienced  
R user) as a clear case of method dispatching. I call something that I  
think most of us think of as a generic, with a function argument and I  
cannot see that possibility when I do a methods("plot"). This use case  
is not entirely far out - I have just been teaching and wanted to show  
how I could see what happened when I called plot on sin and lo and  
behold, plot.function is not in the list of methods("plot")

I can see that there is special code in plot for handling dispatching  
on a function. I can see that is it handled differently (ie. not with  
a call to UseMethod) but from my point of view, the call
   plot(sin)
looks and feels like methods dispatching. I would say plot is a generic.

Finally the help page for plot.function states
## S3 method for class 'function':
      plot(x, y = 0, to = 1, from = y, xlim = NULL, ...)

So I think something should be cleaned up here.

Kasper