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"

> beginYear.Fun(4)
[1] 16

> beginYear(4)
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
>

-- 
Rainer M. Krug, Centre of Excellence for Invasion Biology,
Stellenbosch University, South Africa

______________________________________________
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