[Rd] inconsistencies between ?class and ?UseMethod

Hervé Pagès hpages at fhcrc.org
Tue Dec 4 23:31:48 CET 2012


Hi,

The 2 man pages give inconsistent description of class():

Found in ?class:

      If the object does not have a class attribute, it has an implicit
      class, ‘"matrix"’, ‘"array"’ or the result of ‘mode(x)’ (except
      that integer vectors have implicit class ‘"integer"’).

Found in ?UseMethod:

      Matrices and arrays have class ‘"matrix"’ or‘"array"’ followed
      by the class of the underlying vector.
      Most vectors have class the result of ‘mode(x)’, except that
      integer vectors have class ‘c("integer", "numeric")’ and real
      vectors have class ‘c("double", "numeric")’.

So according to ?UseMethod, class(matrix(1:4)) should be
c("matrix", "integer", "numeric"), which is of course not the case:

   > class(matrix(1:4))
   [1] "matrix"

I wonder if this was ever true, and, if so, when and why it has changed.

Anyway, an update to ?UseMethod would be welcome. Or, documenting
class() in only 1 place seems even better (more DRY principle).

Thanks,
H.

-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the R-devel mailing list