All,
I am creating a mortgage prepayment model package.  The idea is to create a 
class FRMModelFunction and each slot in the class is a function that may be use 
in the prepayment. So I would like to create a generic and method that will 
allow me to call the slot by name.  However, I think that I am missing 
something in my setup

If I run the below code I can do the following

Omega(Model) which returns the function

Omega <- Omega(Model) which then assigns the function and allows me to pass 
values and get a result from Omega(x = 1)

However I can also get a result by directly accessing the slot

Model@Omega(x=1)

What I want to do is set a generic and method so that I can do the following

Omega(x=1)

The below is close but still not what I would like to have.  Is what  I have 
described possible and if so what have I missed?

Glenn 


setGeneric("Omega", function(object,...) {standardGeneric("Omega")})

 setMethod("Omega", signature = "FRMModelFunction", 
           definition = function(object){object@Omega})

 setClass("FRMModelFunction",
          representation(
            Omega = "function"))

 Model <- new("FRMModelFunction",
           Omega = function(x = numeric()) {return(max(0, min(1, x)))}
           )
______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to