>>>>> "TP" == Tony Plate <[EMAIL PROTECTED]> >>>>> on Sat, 05 Jan 2008 12:11:46 -0700 writes:
TP> [EMAIL PROTECTED] wrote: >>>>>>> "TimH" == timh <[EMAIL PROTECTED]> >>>>>>> on Sat, 5 Jan 2008 02:05:08 +0100 (CET) writes: >>>>>>> >> TimH> is() does not catch parent S3 classes: >> >> >> library(splines) >> >> temp <- bs(1:99, df=5) >> >> class(temp) TimH> [1] "bs" "basis" >> >> is(temp, "basis") TimH> [1] FALSE >> TimH> In contrast, is() does catch parent S4 classes: >> >> library(copula) >> >> norm.cop <- ellipCopula("normal", param = c(0.5, 0.6, 0.7), TimH> + dim = 3, dispstr = "un") >> >> is(norm.cop, "copula") TimH> [1] TRUE >> >> class(norm.cop) TimH> [1] "normalCopula" >> >> Yes, that's all correct, but where's the bug? >> >> S3 has *NO* class definitions, so how can there be class >> inheritance? TP> These types of statements make me really confused (and I suspect far TP> more than necessary). Isn't 'inherits()' an S3 function? (at least TP> it's not in package "methods", and it works with S3 classes, while 'is' TP> is in the "methods" package). John already kindly answered, but yes, indeed, my statements must have been somewhat confusing. Prompted by Tim's ("child", "parent"), I was talking about *class* inheritance (which does not exist for S3) but with his question/remark/bug report about is(<obj>, <class>) Tim was really concerned with *objects* inheriting from classes and Tony's answer about inherits() vs is() was well appropriate. When I was talking about class inheritance, I was talking about "parent child relationships" between classes, where "the answer" is extends(), not is(). E.g. > library(Matrix) > extends("dgCMatrix", "CsparseMatrix") [1] TRUE > extends("CsparseMatrix", "sparseMatrix") [1] TRUE > extends("sparseMatrix", "Matrix") [1] TRUE And last year, I've finished a small CRAN package, called 'classGraph', which nicely visualizes such class inheritance by drawing graphs (using the bioconductor packages 'Rgraphviz' and 'graph'): library(Matrix) library(classGraph) cg2. <- class2Graph("dgCMatrix", fullNames=FALSE) plot(cg2.) then produces the attached plot which *is* all about class inheritance, only present in S4, but, again, I apologize for confusing you, since Tim really needed the "class instance" or "object -> class" inheritance. Martin
<<inline: dgCMatrix-class-graph.png>>
______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel