[R] basic question about S4 and methods not found

Gabriel.Cardi at ubs.com Gabriel.Cardi at ubs.com
Mon Mar 14 12:38:55 CET 2011


Hi guys

I have a basic question about S4 stuff

Here is how I do it:

setGenericVerif <-
function(x,y){if(!isGeneric(x)){setGeneric(x,y)}else{}}
# from the genolini intro to S4

# here is the class
setClass("RiskBuckets", 
    representation(
       ... xxx ...
			)
)

# here is the generic f.
setGenericVerif("compute.Gaussian.probs.Cell",
           function(object, mu, sigma, ...)
		     standardGeneric("compute.Gaussian.probs.Cell")
)

# here is the method
setMethod("compute.Gaussian.probs.Cell", "RiskBuckets", 
  function(object, mu, sigma, ...) {
       ... xxx ...
       }
    }
   return(... xxx ...)
  }
)

All that is run with the following:

rm(list=ls())
  # load the classes:
source("../Objects/sourceAllObjects.r")
  # test the classes:
source("test_RiskBuckets.r")

If I run R and try the everything is fine.  :-)
However, is try TO RUN IT AGAIN  (without closing R) I get a message:

Fehler in eval.with.vis(expr, envir, enclos) : 
  konnte Funktion "compute.Gaussian.probs.Cell" nicht finden

(Sorry for the German.) The function is NOT FOUND anymore! How's that?



Best regards

Giuseppe Gabriel Cardi

-------------- next part --------------
Visit our website at http://www.ubs.com

This message contains confidential information and is in...{{dropped:21}}


More information about the R-help mailing list