Re: [R-pkg-devel] Exporting S3 methods for base generics

2017-06-26 Thread Joris Meys
Ah, good point :-) You can avoid that by using inheritance, but now you're on a route to refactoring your entire package actually. See also this question on stackoverflow for a nice example of how this can be done: https://stackoverflow.com/questions/26963900/generalizing-three-dots-argument-disp

Re: [R-pkg-devel] Exporting S3 methods for base generics

2017-06-26 Thread Joris Meys
Hi Charles, that particular construct (with the dots) I only have in proprietary packages, so I can't share the code for those. If you have the package on a repo on github, you can give me a link and a pointer as to what file you're working on, and I can take a look. You also find some nice examp

Re: [R-pkg-devel] Exporting S3 methods for base generics

2017-06-26 Thread Charles Determan
Ah, I see now. I came across this previous post ( http://r.789695.n4.nabble.com/override-pmin-pmax-for-my-own-matrix-td4715903.html) which mentioned the caveat that all the elements passed to ... must be the same. When I pass two of the same class it works but I believe I will need to go back to

Re: [R-pkg-devel] Exporting S3 methods for base generics

2017-06-26 Thread Charles Determan
Could you point to one of these packages you refer to? I'm still having problems and not sure why at the moment. Thanks On Mon, Jun 26, 2017 at 12:32 PM, Joris Meys wrote: > Hi Charles, > > my mistake. I forgot that pmax has an extra argument na.rm. I'm surprised > you could define the method,

Re: [R-pkg-devel] Exporting S3 methods for base generics

2017-06-26 Thread Joris Meys
Hi Charles, my mistake. I forgot that pmax has an extra argument na.rm. I'm surprised you could define the method, as this normally should return an error from conformMethod(). So: #' @rdname pmax setGeneric("pmax", signature = "...") should work. I've used this myself in quite a number of packa

Re: [R-pkg-devel] Exporting S3 methods for base generics

2017-06-26 Thread Charles Determan
Thanks for the reply Joris, although I am not sure what I could be doing wrong. I implement exactly the lines you show and yet I just get the following error when I call 'pmax' on the class. > pmax(x, 0) Error in mmm < each : comparison (3) is possible only for atomic and list types In additio

Re: [R-pkg-devel] Exporting S3 methods for base generics

2017-06-26 Thread Joris Meys
Hi Charles, if a generic exists already in the base, you only have to export the actual S3 method. Your problem is that base::pmax() is not a generic S3 function. So R gives you the correct warning: the S3 generic in your package will always mask the base pmax function. And that's not really a pro

[R-pkg-devel] Exporting S3 methods for base generics

2017-06-26 Thread Charles Determan
Greetings R users, I was wondering how others are exporting S3 methods in their packages when the generic is in 'base'. For example, let's say I want to export a new pmax method. The only way I have found to get this to work is by redefining the function with 'UseMethod' and setting the default