[Rd] removing union class

Martin Maechler maechler at stat.math.ethz.ch
Fri Mar 15 11:39:18 CET 2013

>>>>> Renaud Gaujoux <renaud at mancala.cbio.uct.ac.za>
>>>>>     on Wed, 13 Mar 2013 13:10:44 +0200 writes:

    > Hi,
    > I get the following error when trying to remove a union class:

    >> setClassUnion('a', c('matrix', 'numeric'))
    >> removeClass('a')
    >> sessionInfo()
    > R version 2.15.3 (2013-03-01)
    > Platform: i686-pc-linux-gnu (32-bit)

    > locale:
    > [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    > [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
    > [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
    > [7] LC_PAPER=C                 LC_NAME=C
    > [9] LC_ADDRESS=C               LC_TELEPHONE=C

    > attached base packages:
    > [1] stats     graphics  grDevices utils     datasets  methods   base

    > Is this normal? Am I doing something wrong?

Well,... you forgot to show the error (and the traceback) :

  > setClassUnion('a', c('matrix', 'numeric'))
  > removeClass('a')
  Error in .getClassFromCache(Class, where) : node stack overflow

  > traceback()
  1888: .getClassFromCache(Class, where)
  1887: getClass(cl)
  1886: checkAtAssignment("classRepresentation", "contains", "list")
  1885: .deleteSuperClass(cdef, superclass)
  1884: .removeSuperClass(subclass, superclass)
  3: .deleteSuperClass(cdef, superclass)
  2: .removeSuperClass(what, Class)
  1: removeClass("a")

So that looks indeed like a bug in R's  removeClass() or its
helper functions.
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


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.

    > Thank you.

    > Bests,
    > Renaud

Thank you for the report... although it would have been great if
it had come earlier, as we are approaching feature freeze for
3.0.0 very rapidly.

Martin Maechler, ETH Zurich

More information about the R-devel mailing list