Re: [Rd] S4 method dispatch sometimes leads to incorrect when object loaded from file?

2015-05-12 Thread Martin Morgan
On 05/12/2015 05:31 AM, Martin Maechler wrote: Martin Morgan on Mon, 11 May 2015 10:18:07 -0700 writes: > On 05/10/2015 08:19 AM, Martin Morgan wrote: >> Loading an S4 object from a file without first loading the library sometimes (?, >> the example below and actual exampl

Re: [Rd] S4 method dispatch sometimes leads to incorrect when object loaded from file?

2015-05-12 Thread Martin Maechler
> Martin Morgan > on Mon, 11 May 2015 10:18:07 -0700 writes: > On 05/10/2015 08:19 AM, Martin Morgan wrote: >> Loading an S4 object from a file without first loading the library sometimes (?, >> the example below and actual example involves a virtual base class and the s

Re: [Rd] S4 method dispatch sometimes leads to incorrect when object loaded from file?

2015-05-11 Thread Martin Morgan
On 05/10/2015 08:19 AM, Martin Morgan wrote: Loading an S4 object from a file without first loading the library sometimes (?, the example below and actual example involves a virtual base class and the show generic) leads to incorrect dispatch (to the base class method). The attached package repr

[Rd] S4 method dispatch sometimes leads to incorrect when object loaded from file?

2015-05-10 Thread Martin Morgan
Loading an S4 object from a file without first loading the library sometimes (?, the example below and actual example involves a virtual base class and the show generic) leads to incorrect dispatch (to the base class method). The attached package reproduces the problem. It has setClass("A") se

Re: [Rd] S4 Method Dispatch for Class Defined as Attribute

2014-10-07 Thread Sven E. Templer
Is setOldClass the solution? e.g. x <- list() class(x) <- "foo" setGeneric("bar", function(x) "bar generic") setOldClass("foo") setMethod("bar", "foo", function(x) "bar foo") bar(x) On 7 October 2014 10:00, Dario Strbenac wrote: > Hello, > > I am writing an interface to some functions from the

[Rd] S4 Method Dispatch for Class Defined as Attribute

2014-10-07 Thread Dario Strbenac
Hello, I am writing an interface to some functions from the CRAN package pamr, which is poorly written. I have a S4 method I declared with setMethod. I'd like to provide a signature of "pamrtrained" which is the class of object that training creates. The last two lines of code of pamr.train ar

Re: [Rd] S4 method dispatch

2011-09-30 Thread John Chambers
On 9/30/11 12:48 AM, Edzer Pebesma wrote: Thanks, John! I did not manage to figure out how the strict= works, but changed class inheritance such that simple inheritance did not take place. I see you're advocating to use the contains= to stress inheritance; back in 2005, I followed the green b

Re: [Rd] S4 method dispatch

2011-09-30 Thread Edzer Pebesma
Thanks, John! I did not manage to figure out how the strict= works, but changed class inheritance such that simple inheritance did not take place. I see you're advocating to use the contains= to stress inheritance; back in 2005, I followed the green book, which did not yet have this. If I n

Re: [Rd] S4 method dispatch

2011-09-18 Thread John Chambers
The distinction here is "simple inheritance" ("Software for Data Analysis", p. 346). Your first example is simple inheritance (would be clearer if you used the contains= argument). In the second version you supply an explicit coerce method, so method dispatch can no longer just pass in the o

Re: [Rd] S4 method dispatch

2011-09-18 Thread Edzer Pebesma
As a follow-up, I managed to isolate the problem I sent earlier this week, and reduced it to a small case (I'm using R 2.13.1, i486-pc-linux-gnu (32-bit)). The following script does what I expect: setClass("A", representation(x = "numeric")) setClass("AB", representation("A")) setGeneric("doNot

[Rd] S4 method dispatch

2011-09-15 Thread Edzer Pebesma
List, In order to get rid of some old, unreadable S3 code in package sp, I'm trying to rewrite things using S4 methods. Somewhere I fail, and I cannot sort out why. In order to isolate the problem, I created two functions, doNothing<- and dosth, and both should do nothing. The issue is that in mos

Re: [Rd] S4 method dispatch and namespaces: why is default method selected

2009-05-19 Thread Michał Bojanowski
Hi Martin, >> However, when I put all these in a package with Depends field in >> DESCRIPTION having: methods, pixmap, and with the following namespace: >> >> >> importFrom("graphics", "plot") >> exportClasses("myclass") >> exportMethods("plot") >> >> >> things stop working (this is from package t

Re: [Rd] S4 method dispatch and namespaces: why is default method selected

2009-05-18 Thread Martin Morgan
Hi Michał -- Michał Bojanowski writes: > Hi, > > I ran into the following peculiarity involving S4 method dispatch and > namespaces. > > I develop a package which have a namespace and which depends on 'pixmap' > package, which itself does not have a namespace. > > Now, in my package I have a cla

[Rd] S4 method dispatch and namespaces: why is default method selected

2009-05-18 Thread Michał Bojanowski
Hi, I ran into the following peculiarity involving S4 method dispatch and namespaces. I develop a package which have a namespace and which depends on 'pixmap' package, which itself does not have a namespace. Now, in my package I have a class which has a slot for objects from class "pixmap" and I

Re: [Rd] S4 Method dispatch in recent 2.4.0alpha

2006-09-13 Thread Oosting, J. \(PATH\)
I have tried it on the patched version of R, and it works now. Thanks, Jan Van: John Chambers [mailto:[EMAIL PROTECTED] Although there is not enough information to be sure, this may be related to an issue uncovered in other testing, for which a patch has ju

Re: [Rd] S4 Method dispatch in recent 2.4.0alpha

2006-09-13 Thread John Chambers
Although there is not enough information to be sure, this may be related to an issue uncovered in other testing, for which a patch has just been committed. The issue arises if the same generic function is defined in several packages. For example, Matrix and msbase both have methods for the p

Re: [Rd] S4 Method dispatch in recent 2.4.0alpha

2006-09-12 Thread Oosting, J. \(PATH\)
Your suggestions worked ok in the example, but in my case there is yet another package that implements a plot method. Now the plotting from within the package works, but plotting from outside the package, on the console, gives an error as if plot.default is invoked. > class(myplot) [1] "gt.barplo

Re: [Rd] S4 Method dispatch in recent 2.4.0alpha

2006-09-11 Thread John Chambers
Good example. The basic problem is in the NAMESPACE file: importFrom(graphics, plot) But the version of plot() in the graphics package is not a generic function. Therefore, when your mpplot() calls it there is no method dispatch. You need to import the generic version of plot() from minipk

[Rd] S4 Method dispatch in recent 2.4.0alpha

2006-09-11 Thread Oosting, J. \(PATH\)
I use 2 packages that both implement a S4 plot method, where one package depends on the other (the bioconductor package globaltest which depends on multtest). When the plot method is used from within the package, it seems the default plot method is used, and an error is generated. When the method i