Rainer M Krug wrote:
Hi
I want to create a new generic method, but I end up with an error
(evaluation nested too deeply). see the transcript below.
The function beginYear.Fun() works, but not beginYear.
I have no idea why.
Any ideas welcome,
Rainer
setClass("fun", representation(x = "numeric"))
[1] "fun"
new("fun")
An object of class “fun”
Slot "x":
numeric(0)
setGeneric(
"beginYear",
function(object, ...) standardGeneric("beginYear")
)
setGeneric(
+ "beginYear",
+ function(object, ...) standardGeneric("beginYear")
+ )
[1] "beginYear"
beginYear.Fun = function(x) x^2
beginYear.Fun(4)
[1] 16
setMethod(
"beginYear",
signature( object = "numeric" ),
beginYear
)
setMethod(
+ "beginYear",
+ signature( object = "numeric" ),
+ beginYear
+ )
[1] "beginYear"
.... because the method function you want to call is beginYear.Fun
rather than beginYear as declared in the method specification?
Uwe Ligges
beginYear.Fun(4)
[1] 16
beginYear(4)
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
______________________________________________
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.