[Rd] S4 class no longer accepts matrix in array slot under 2.0.1

From: Giles Heywood <giles.heywood_at_cantab.net>
Date: Mon 10 Jan 2005 - 08:38:54 EST


I have an S4 class with a slot of class "array", and in upgrading to 2.0.1 (from 1.9.1) I have encountered a change in behaviour. This causes me some difficulties if I want to allow 2-dimensional arrays in the slot.

The following (in 2.0.1) illustrates the point:

> setClass("foo",representation("array"))
[1] "foo"
> a <- new("foo",array(NA,2:4))
> b <- new("foo",matrix(NA,2,3))

Error in "as<-"(`*tmp*`, Classi, value = c(NA, NA, NA, NA, NA, NA)) :

        No method or default for as() replacement of "foo" with Class="matrix"

This last error did not occur under 1.9.1.

I conclude that in this context the methods package does not recognise "matrix" as a subclass of "array". However if I use getClass(), I see that R recognises "matrix" as a subclass of "array" (and vice-versa). So is this new behaviour correct?

[this is a re-posting to R-devel of a question earlier posted to R-help, which attracted limited response]



R-devel@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Jan 10 07:45:54 2005

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:02:33 EST