Skip to content
Prev 2036 / 63424 Next

R's UseMethod() does not dispatch on changed class() (PR#167)

On 15 Apr 1999, Peter Dalgaard BSA wrote:

            
Often by certain people with a massive presence!

We have indeed been here before.  In our lda function we do

class(x) <- data.class(x)
UseMethod("lda")

That fails to use the new class in R, and according to `your' reading of
the White book (but not mine nor apparently the author of S's) should do
so. `You' suggested

   UseMethod("lda", x, ...)

which works in some versions of S-PLUS 3.x but crashes the DEC Alpha
version and works on no version of S-PLUS 5.x. Hence I have

lda <- function(x, ...)
{
   if(is.null(class(x))) class(x) <- data.class(x)
#ifdef R
   UseMethod("lda", x, ...)
#ifdef SP3
   UseMethod("lda")
}

and in SP5 I do something with new-style classes.
and not just Joe User....

Brian