Re: [R] oldClass vs. class

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Sat 06 Aug 2005 - 16:50:02 EST

On Sat, 6 Aug 2005, ronggui wrote:

> Hi,When I read the source of str,i find these code
> -----
> ## Show further classes // Assume that they do NOT have an own Method --
> ## not quite perfect ! (.Class = 'remaining classes', starting with current)
> cl <- oldClass(object); cl <- cl[cl != "data.frame"] #- not THIS
> class -----

> so I use ?oldClass to try to learn more about oldClass.But
> after I have reading all the help page ,I still have no idea the
> diiference between oldClass and class.

>From the help page

      Many R objects have a 'class' attribute, a character vector giving
      the names of the classes which the object "inherits" from.  If the
      object does not have a class attribute, it has an implicit class,
      '"matrix"', '"array"' or the result of 'mode(x)'.  (Functions
      'oldClass' and 'oldClass<-' get and set the attribute, which can
      also be done directly.)

so class returns the implicit class, and oldClass does not.

> A <- matrix(1:6, 2,3)
> class(A)
[1] "matrix"
> oldClass(A)

NULL just as it says.

-- 
Brian D. Ripley,                  ripley@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Aug 06 16:55:31 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:07:25 EST