Hi

I have some problems in defining new generic functions and classes. Just
have a look at the following example:


require(fPortfolio)

setClass("PROBECLASS",           
  representation(               
    type="character"            
  )                             
)       

isGeneric("setType<-")
#Returns 
TRUE

#I would like to define a specific function for class PROBECLASS with other
arguments than for the generic function "setType" of fPortfolio.
setGeneric("setType<-", function(object, value)
standardGeneric("setType<-"))

#Returns
Fehler in makeGeneric(name, fdef, fdeflt, group = group, valueClass =
valueClass,  : 
  the formal arguments of the generic function for "setType<-" (object,
value) differ from those of the non-generic to be used as the default (spec,
value)

setReplaceMethod("setType", "PROBECLASS", function(object, value){

  [EMAIL PROTECTED] <- value                           
  object

})           

#Example
obj = new("PROBECLASS")
setType(obj) = "test"
obj         


######
If I don't require fPortfolio it works fine. However, is it not possible to
create two generic functions with the same name but different arguments?
setType for fPortfolio may be differ completely from setType of
PROBECLASS...
What's the best way to have functions which belongs to an object of a
specific class? I had a look at the paper "S4 Classes in 15 pages, more or
less" (feb12, 2003), however, I could not found what I did wrong...

Any help is highly appreciated. 

Thanks
Dominik

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to