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 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