[Rd] is(x, "parent") returns FALSE when class(x) is c("child", "parent") (PR#10549)

maechler at stat.math.ethz.ch maechler at stat.math.ethz.ch
Sat Jan 5 11:00:15 CET 2008


>>>>> "TimH" == timh  <timh at insightful.com>
>>>>>     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?
There's many reasons to go from S3 to S4, and the lack of class
definitions in S3 is an important one...

Now, still being curious:  Are you implicitly saying that in S-plus,
is() behaves differently, namely 
``as if S3 classes would exist?'' (:-)

[Of course, I understand what you mean, and I agree that
 normally, the S3  class attribute  c("ch", "pr") means that "ch"
 is conceptually a child of "pr".
 
 However, there's at least one exception in R {which I have found a
 bit unfortunate, but never followed up}:

   > class(Sys.time())
   [1] "POSIXt"  "POSIXct"
]

Regards,
Martin

    TimH> Version:
    .....
    TimH> version.string = R version 2.6.1 (2007-11-26)
    .....



More information about the R-devel mailing list