[R] warning on generic function when building R package

carol white wht_crl at yahoo.com
Mon Oct 19 21:50:56 CEST 2015


Thanks Murdoch.
defining
plot.func<- function(x=x.init, y=y.init, arg3, arg4, "title", col, arg5)
and if plot doesn't take the exact parameters of plot.func but modified of these parametersplot(x=x.pt,y=y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab", ylab="ylab", main = "title", col = col,type = "l")  
then, how to define and invoke to be consisent?
Regards,

     On Monday, October 19, 2015 7:45 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
   

 On 19/10/2015 1:29 PM, carol white via R-help wrote:
> Hi,I have invoked plot in a function (plot.func) as follows but when I check the built package, I get a warning:
> plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab", ylab="ylab", main = "title", col = col,type = "l") 
> R CMD check my.package
> checking S3 generic/method consistency ... WARNING
> plot:
>  function(x, ...)
> plot.func:
>  function(x.pt, y.pt, arg3, arg4, "title", col, arg5)
> 
> See section ‘Generic functions and methods’ in the ‘Writing R
> Extensions’ manual.
> Which plot argument is illegitimate or missing and how to eliminate the warning?

The first argument to plot.func needs to be called "x" if you want to
use it as a method.  Method signatures need to be consistent with the
generic signature.

Duncan Murdoch



  
	[[alternative HTML version deleted]]



More information about the R-help mailing list