Re: [R-pkg-devel] Redefinition of generic for plot function breaks plot.formula

2015-09-01 Thread Kevin Ushey
FWIW, it's a very _very_ bad idea to add methods to S3 generics for classes you don't 'own'. Some code might be written with the expectation that `plot(df)` actually does dispatch to `plot.default`. This implies that simply loading your package would break code in surprising ways. I would strongly

Re: [R-pkg-devel] Redefinition of generic for plot function breaks plot.formula

2015-09-01 Thread Benjamin Hofner
Dear Gavin, you and Hadley seem to be right. It looks like a problem which is buried deeper within R and the method dispatch. It seems like I have to reintroduce the class labeled.data.frame and plot.labeled.data.frame. However, I will post on R-devel to try to understand this issue. Thanks

Re: [R-pkg-devel] Redefinition of generic for plot function breaks plot.formula

2015-09-01 Thread Gavin Simpson
It's not just plot.formula that is broken; plot.lm is dead too for example. It's seems that just unexported methods fail to be called. This works plot(ts(1:100)), correctly calling the plot.ts method. What you must be doing overwriting the plot generic seems to be clobbering S3 dispatch or killing

Re: [R-pkg-devel] Redefinition of generic for plot function breaks plot.formula

2015-09-01 Thread William Dunlap
Try giving y a default value, NULL, in your plot.default: plot.default <- function(x, y=NULL, ...) graphics::plot(x, y, ...) Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Aug 31, 2015 at 7:37 PM, Gavin Simpson wrote: > Why do you even need to take over `plot`, `plot.default`?

Re: [R-pkg-devel] Redefinition of generic for plot function breaks plot.formula

2015-09-01 Thread Benjamin Hofner
I am using it this way as I want to be able to plot data.frames but have a better display and more options. Thus, using plot.data.frame seems rather natural. A different function or new classes are just a work around. I do not want to use a new class as these functions should work on ANY data f

Re: [R-pkg-devel] Redefinition of generic for plot function breaks plot.formula

2015-09-01 Thread Gavin Simpson
...or have an object that is a data.frame but to which you add an additional class class(obj) <- c("my_df", "data.frame") Then you can include plot.my_df() in your package, plus a function to create a my_df object from a data frame, and you don't have to worry about all this and your objects will

Re: [R-pkg-devel] Redefinition of generic for plot function breaks plot.formula

2015-09-01 Thread Hadley Wickham
Why don't you just create your own function? Hadley On Tue, Sep 1, 2015 at 8:08 AM, Benjamin Hofner wrote: > Dear Gavin, > > unfortunately, I cannot overwrite plot.data.frame only. If I do this I > get the following warning from R CMD check: > > * checking use of S3 registration ... WARNING > Re

Re: [R-pkg-devel] Redefinition of generic for plot function breaks plot.formula

2015-09-01 Thread Benjamin Hofner
Dear Gavin, unfortunately, I cannot overwrite plot.data.frame only. If I do this I get the following warning from R CMD check: * checking use of S3 registration ... WARNING Registered S3 method from a standard package overwritten by 'papeR': method from plot.data.frame graphics The reason for t

Re: [R-pkg-devel] Redefinition of generic for plot function breaks plot.formula

2015-08-31 Thread Gavin Simpson
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

[R-pkg-devel] Redefinition of generic for plot function breaks plot.formula

2015-08-31 Thread Benjamin Hofner
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