From giles.heywood at cantab.net  Sun Jan  9 22:38:54 2005
From: giles.heywood at cantab.net (Giles Heywood)
Date: Sun Jan  9 22:38:57 2005
Subject: [Rd] S4 class no longer accepts matrix in array slot under 2.0.1
Message-ID: <KLEHJMEACMGEMBOOPFCAAEJPCAAA.giles.heywood@cantab.net>

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]


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