[R] Classes in R

Randall Skelton rhskelto at atm.ox.ac.uk
Thu Oct 25 18:27:13 CEST 2001


Two quick questions.

First, why doesn't using the matrix function actually set the class of the
resulting object to "matrix"?

> a <- matrix(1,10,10)
> attributes(a)
 $dim
 [1] 10 10

or should I be using?

> a <- matrix(1,10,10); class(a) <- c("matrix");
> attributes(a)
$dim
[1] 10 10

$class
[1] "matrix"

Second, can somone please send me an example showing how inheritance works
in R?  The R Language Definition document isn't particularly clear on the
subject... i.e. NextMethod lacks a good example.

Cheers,
Randall

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list