Stack Exchange
R -- adding method to a class
I am trying to add a method to a class:
setClass("cox.boost", slots=c(CoxBoost="CoxBoost"))
setGeneric("predictSurvProb", function(object) standardGeneric("predictSurvProb"))
  setMethod("predictSurvProb", signature(object="cox.boost"), function(object) predict(object=object, newdata=NULL, newtime=NULL, newstatus=NULL, type="risk", times=NULL))
>   setGeneric("predictSurvProb", function(object) standardGeneric("predictSurvProb"))
[1] "predictSurvProb"
>   setMethod("predictSurvProb", signature(object="cox.boost"), function(object) predict(object=object, newdata=NULL, newtime=NULL, newstatus=NULL, type="risk", times=NULL))
[1] "predictSurvProb"
> findMethods("cox.boost")
list()
Warning message:
In findMethods("cox.boost") :
  non-generic function 'cox.boost' given to findMethods()

The method is not added to the class. Could anyone please help me?

In order to see the methods of a class, you would use the following:
methods(class = "cox.boost")

Whereas findMethods would be used on a generic, i.e. like:
findMethods("predictSurvProb")


You were saying that the method is not added to the class. I am instead saying that it is actually added, just that your way of checking is not correct. Or is your question a different one?

Sorry. I mistook.
Thanks for help.
