[Rd] Subsetting using dimnames on S4 array-based class
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Feb 17 14:13:20 CET 2005
On Thu, 17 Feb 2005, Iago Mosqueira wrote:
> On Thu, 2005-02-17 at 12:32, Prof Brian Ripley wrote:
>
>> and you are talking about *names of* dimnames).
>
> Sorry for the confusion.
>
>> It `works' for arrays because the definition there (in ?Extract) is not
>> the same as the generic you are using: notice the ... in the definitions,
>> and for arrays it is really "["(x, ..., drop=TRUE) and the names of ...
>> are ignored.
>
> Thanks. I did realise for arrays the names are ignored, but in the new
> class they are not even accepted.
>
>> so argument names are ignored for the primitives, but not for S3 methods
>> (and I believe not for S4 methods).
>
> I am afraid I fail to see then why my example code fails to accept names
> when subsetting. Shouldn't a class that extends "array" inherit this
> behaviour too?
No, it inherits from the S4 pseudo-method for "array", not the primitive.
Remember that S4 methods are bolted on to a different system, and bridging
the gaps where possible has been very hard work (by John Chambers).
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list