[R-pkg-devel] Redefinition of generic for plot function breaks plot.formula
Gavin Simpson
ucfagls at gmail.com
Tue Sep 1 04:37:51 CEST 2015
Why do you even need to take over `plot`, `plot.default`? You can just
register/export the plot.data.frame method from our package without
touching the generic or default method. The part of WRE that you refer to
is about making functions that are *not* S3 methods in one of base R or
it's packages into S3 generics. You are just providing a method for an
existing generic so you don't need to follow that code.
That said, it wouldn't be good form to fundamentally alter the way
plot.data.frame worked as users might expect certain functionality.
HTH
G
On 31 August 2015 at 04:03, Benjamin Hofner <benjamin.hofner at fau.de> wrote:
> Dear all,
>
> CRAN policies do not allow that single methods (for generic functions)
> which are defined in base or recommended packages are replaced. They advice
> package authors to replace the standard generic and use a xxx.default
> method which then calls the original standard generic.
>
> Using the following code
>
>
> ## overwrite standard generic
> plot <- function(x, y, ...)
> UseMethod("plot")
>
> ## per default fall back to standard generic
> plot.default <- function(x, y, ...)
> graphics::plot(x, y, ...)
>
> ## now specify modified plot function for data frames
> plot.data.frame <- function(x, variables = names(x), ...)
>
>
> essentially works for all tested plot.xxx functions. Yet, it breaks
> plot.formula. How can I proceed to overwrite plot.data.frame without
> breaking plot.formula. Any help is greatly appreciated.
>
> For a detailed description of the problem with syntax highlighting and
> code to reproduce the problem please see:
>
>
> http://stackoverflow.com/questions/32246361/redefinition-of-generic-for-plot-function-breaks-plot-formula
>
> Best,
> Benjamin
> --
>
> ******************************************************************************
> Dr. rer. nat. Benjamin Hofner
>
> Institut für Medizininformatik, Biometrie und Epidemiologie
> Friedrich-Alexander-Universität Erlangen-Nürnberg
> Waldstr. 6 - 91054 Erlangen - Germany
>
> Tel: +49-9131-85-22707
> Fax: +49-9131-85-25740
>
> Büro:
> Raum 3.036
> Universitätsstraße 22
> (Eingang linke Seite des Gebäudes; Wegweiser IMBE)
>
> benjamin.hofner at fau.de
>
> http://www.imbe.med.uni-erlangen.de/cms/benjamin_hofner.html
> http://www.benjaminhofner.de
>
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
--
Gavin Simpson, PhD
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list