[R-pkg-devel] Problems with :::

Martin Maechler maechler at stat.math.ethz.ch
Mon Feb 1 09:49:26 CET 2016


>>>>> Kirill Müller <kirill.mueller at ivt.baug.ethz.ch>
>>>>>     on Thu, 28 Jan 2016 17:42:12 +0100 writes:

    > On 28.01.2016 14:20, Duncan Murdoch wrote:
    >> If the class is just "mytable", then you'll have to
    >> change it to "ftable" before calling stats::format().
    > Side note: The following will fail, because format.ftable
    > double-checks the class of its argument:

    > format_ftable <- utils::getS3method("format", "ftable")
    > format_ftable(mytable)

    > -Kirill

Well, I don't think it would fail as that does

    if (!inherits(x, "ftable")) 
        stop("'x' must be an \"ftable\" object")

and the OP did mention that his objects were flat tables.

Note that the above is *good style* as opposed to the  "bad"
code I've seen so often in packages (and otherwise) which would
use something like

   if(class(x) == "ftable")  ## really really bad

because that code will work incorrectly for objects with S3
class attribute, say   c("myFtable", "ftable")

Martin



More information about the R-package-devel mailing list