[Rd] promptClass misses methods

Martin Maechler maechler at stat.math.ethz.ch
Fri Dec 1 11:37:46 CET 2006

>>>>> "RossB" == Ross Boylan <ross at biostat.ucsf.edu>
>>>>>     on Thu, 30 Nov 2006 22:29:06 -0800 writes:

    RossB> I've had repeated problems with promptClass missing
    RossB> methods, usually telling me a class has no methods
    RossB> when it does.

    RossB> In my current case, I've defined an S4 class
    RossB> "mspathCoefficients" with a print method
    RossB> setMethod("print", signature(x="mspathCoefficients"),
    RossB> function(x, ...)  { # etc

You should *not* define "print" methods for S4 classes;
rather you should define "show" methods.

    RossB> The file promptClass creates has no methods in it.
    >> showMethods(classes="mspathCoefficients")
    RossB> Function: initialize (package methods)
    RossB> .Object="mspathCoefficients" (inherited from:
    RossB> .Object="ANY")

so it's just inherited from "ANY"

    RossB> Function: print (package base) 
    RossB> x="mspathCoefficients"

that's the one

    RossB> Function: show (package methods)
    RossB> object="mspathCoefficients"
    RossB>  (inherited from: object="ANY")
so it's just inherited from "ANY"

Ross, it would really be more polite to your readers if you
followed the posting guide and posted complete
fully-reproducible code...

    >> getGeneric("print")
    RossB> standardGeneric for "print" defined from package
    RossB> "base"

    RossB> function (x, ...)  standardGeneric("print")
    RossB> <environment: 0x84f2d88> Methods may be defined for
    RossB> arguments: x

    RossB> I've looked through the code for promptClass, but
    RossB> nothing popped out at me.

    RossB> It may be relevant that I'm running under ESS in
    RossB> emacs.  However, I get the same results running R
    RossB> from the command line.

    RossB> Can anyone tell me what's going on here?  This is
    RossB> with R 2.4, and I'm not currently using any namespace
    RossB> for my definitions.

[and not a package either?]

I'm very willing to look at this, once
you've provided what the posting guide asks for, see above.


More information about the R-devel mailing list