[Rd] S3 fonctions for object of S4 class

Parlamis Franklin fparlamis at mac.com
Thu Aug 24 00:30:06 CEST 2006


Franck:

I suspect you'll have to include the exact wording of the relevant  
setGeneric and setMethod calls (as well as any other functions called  
in your method) to get an answer to your question.  I just did:

 > setGeneric("start", function(x, ...) standardGeneric("start"))
[1] "start"
 > setMethod("start", signature(x = "numeric"), function(x) x^2)
[1] "start"
 > start(ts(1:10, frequency = 4, start = c(1959, 2)))
[1] 1959    2
 > start(4)
[1] 16

so there does not seem to be a problem with combining S3 and S4  
dispatch.

Franklin

On Aug 23, 2006, at 11:23 AM, Franck Arnaud wrote:

> Hello !
> there's a S3 method called start (and end too) to be used with  
> objects of
> class ts (package stats). I am writing a S4 class for which I would  
> like to
> use this function start, so that start with a ts calls the former  
> method and
> start with my S4 class (called MA) calls the function I want.
> For the 'plot' command I do :
> setGeneric("plot",function(x,y,...) standardGeneric("plot"))
> and
> setMethod("plot",signature(x="MA",y="ANY"),function(x,y,...)
> plotMA(x,y,...))
> and it works just fine.
>
> When I try this with start, I does not work at all : the old  
> function and
> the new do not work. I get an error during the check and when I  
> execute
> commands, the error is like evaluations are too deeply nested (I'm  
> not sure
> of the translation).
>
> I've tried to look for information (in mailing lists, WRE,  
> Rlang,...), but
> i'm kinda lost... Any help appreciated !
>
> Thanks
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list