[Rd] removing union class

Martin Maechler maechler at stat.math.ethz.ch
Tue Mar 19 17:16:42 CET 2013

>>>>> "RG" == Renaud Gaujoux <renaud at mancala.cbio.uct.ac.za>
>>>>>     on Sun, 17 Mar 2013 10:38:44 +0200 writes:

    RG> Late report is better than never isn't it? :)
    >> > Well,... you forgot to show the error (and the
    >> traceback) :

    RG> Apologies, I usually include them (and sessionInfo ...).

    >> > Note that this problem is somewhat dependent on the use
    >> of the > infamous "matrix" class {not properly defined as
    >> a class in S3, > as it may or may not have dimnames, and
    >> then tried to be made S4 > compatible "as well as
    >> possible" in the methods package, see

    RG> Ok. What I want to do is to define a class in my
    RG> namespace that gather some matrix-like classes so that I
    RG> can define a set of common functions for them.
    RG> Initially I want matrix and ExpressionSet objects, and
    RG> possibly add array objects later.  Union classes seem to
    RG> be exactly the way to go, but maybe there is an
    RG> alternative?

There's really *no* problem with class unions.
They work fine and nicely... we also use them in the Matrix
package (part of the R distro).

The problem you've reported is only a propblem of removeClass().


    >> > Of course, I could not have thought of a realistic
    >> situation > where this was a problem, but then you
    >> exemplify one :
    >> >> Hadley, this is problematic for devtools, because
    >> load_all tries to cleanup >> S4 classes when an error
    >> occurs when loading a development package and >> crashes
    >> with no hint on the original error.
    RG> I guess a quick fix for devtools, would be to wrap the
    RG> cleanup procedure into a try or tryCatch (Hadley?).

    RG> Thanks, Renaud

More information about the R-devel mailing list