[R] Error in doc of corresp?

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Nov 12 12:19:37 CET 2001


Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:

> On Mon, 12 Nov 2001, Agustin Lobo wrote:
> 
> > I think that there is a problem in the doc
> > of MASS function corresp:
> 
> No, the problem is in R itself.  Remember MASS is a port from S code, and
> this works as documented in S.  I am fairly sure it once worked in R too.
> 
> Try calling corresp.matrix directly to work around an R bug.
> 
> corresp is
> 
> > corresp
> function (x, ...)
> {
>     if (is.null(class(x)))
>         class(x) <- data.class(x)
>     UseMethod("corresp")
> }
> 
> That correctly sets the class of x to "matrix", but it then dispatches
> corresp.default, even though corresp.matrix exists.

Not sure this is a bug. Not a very useful feature either, though...

It is as far as I can see behaving according to the documentation. To
force dispatch based on the modified x , you could use
UseMethod("corresp", x). As in

> f.matrix <- function(x)print("matrix")
> f <- function(x) {if(is.null(class(x))) class(x) <- data.class(x);UseMethod("f")}
> m <- matrix(1:4,2)
> f(m)
Error in f(m) : no applicable method for "f"
> f <- function(x) {if(is.null(class(x))) class(x) <- data.class(x);UseMethod("f",x)}
> f(m)
[1] "matrix"



-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list