[R] inheritence in S4

cgenolin at u-paris10.fr cgenolin at u-paris10.fr
Mon Mar 24 10:42:04 CET 2008


Hi Martin

I am re reading all the mail we exchange with new eyes because of all 
the thing I learn in the past few weeks. That very interesting and some 
new question occurs...

***********************************
Once, you speak about callGeneric :

setClass("A", representation(x="numeric"))
setClass("C", contains=c("A"))

setMethod("show", "A", function(object) cat("A\n"))
setMethod("show", "C", function(object) {
   callGeneric(as(object, "A"))
   cat("C\n")
})

new("C")

Considere the following definition (that you more or less teach me with 
your yesterday remarques...) :

setMethod("show", "C", function(object) {
   callNextMethod()
   cat("C\n")
})

In this case, is there any difference between the former and the latter ?
Which one would you use ?

(I get that in more complicate case, for example if
setClass("C", contains=c("A","B")), it might be more complicate to use 
the latter, right ?)




*************************
This works :

setMethod("initialize","B",
          function(.Object,..., yValue){
              callNextMethod(.Object, ..., y=yValue)
              return(.Object)
          })
new("B",yValue=3)

but this does not :

setMethod("initialize","B",
          function(.Object, yValue){
              callNextMethod(.Object, y=yValue)
              return(.Object)
          })
new("B",yValue=3)

Why ?
Is there any help page about ... ?


**************************
showMethods gives the list of all the method. Is there a way to see all 
the method for a specific signature IN THE ORDER they will be call by 
callNextMethod ?
If ANY <- D <- E, a method that will gives :

Function "initialize":
.Object = "E"
.Object = "D"
.Object = "ANY"

Thanks for your help
And happy easter eggs !

Christophe


----------------------------------------------------------------
Ce message a ete envoye par IMP, grace a l'Universite Paris 10 Nanterre



More information about the R-help mailing list