[R] avoid s3 methods

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Oct 18 11:43:06 CEST 2011



On 18.10.2011 10:37, Nicola Sturaro Sommacal wrote:
> Hello everybody.
>
> My issue arise when I build a package with my functions. This package is for
> personal purposes only and it will not submitted to CRAN.
>
> Anyway, this may be an opportunity for myself to clear the S3 methods
> concept. I read the R manual and some books about R programming but they are
> usually S4 oriented.
>
> I call a function plot.days(). When I check the package I obtain some
> inconsistencies because this function is a method of the plot() function and
> it requires at least the same arguments.
>
> Since an object call days doesn't exist, I am not interested to access my
> function using plot() but I would like to name it plot.days().
>
> Is there anyway to declare that my plot.days() function is not a method for
> the plot() function?
>
> I hope the question is clear, despite methods are a new world for me.


The S3 method definition happens only by the name of the method: 
"NameOfTheGeneric.Class". Hence plot.days is by definition a method for 
the "plot" generic for objects of class "days". If you want a function 
that is not such a method, rename it. plot_days will do, for example.

Uwe Ligges



> Thank you very much.
>
> Regards,
> Nicola
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list