Skip to content
Prev 57705 / 63424 Next

class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."]

On 11/11/19 01:40, Martin Maechler wrote:
%-/  (<- ASCII version of the rolling eyes emoji)

<ranting mode>

The most cryptic of the 3 forms being by far:

    "<someclass>" %in% class(x)

You need to be able to read thru this to understand that the intend is 
to find out whether 'x' belongs to class "<someclass>" or to one of its 
subclasses. What could be more natural and readable than using 
inherits(x, "<someclass>") for that? What's unusual or intimidating 
about its syntax?

OK I could see that maybe some people would like to be able to use a 
binary operator instead of a function call for this (a la instanceof in 
Java):

   `%inherits%` <- inherits

   library(data.table)

   x <- data.table()
   x %inherits% "data.frame"
   [1] TRUE

which would be a reasonable request (looks cute).

But trying to make the case for "<someclass>" %in% class(x) on 
Twitter??!  %-/

</ranting mode>

H.

  
    

Thread (24 messages)

Martin Maechler head.matrix can return 1000s of columns -- limit to n or add new argument? Nov 1 Gabriel Becker head.matrix can return 1000s of columns -- limit to n or add new argument? Nov 2 Gabriel Becker head.matrix can return 1000s of columns -- limit to n or add new argument? Nov 2 Martin Maechler class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 10 Bryan Hanson class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 10 Duncan Murdoch class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 10 Martin Maechler class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 11 Hervé Pagès class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 11 Abby Spurdle class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 12 Hervé Pagès class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 12 Abby Spurdle class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 12 Hervé Pagès class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 13 Hadley Wickham class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 14 Hervé Pagès class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 14 Martin Maechler class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 15 Martin Maechler _R_CHECK_LENGTH_1_LOGIC2_ setting and Rstudio .. Nov 15 Henrik Bengtsson _R_CHECK_LENGTH_1_LOGIC2_ setting and Rstudio .. Nov 15 Abby Spurdle class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 15 William Dunlap class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 15 Dénes Tóth class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."] Nov 15 Martin Maechler class(<matrix>) |--> c("matrix", "arrary") -- and S3 dispatch Nov 21 Dirk Eddelbuettel class(<matrix>) |--> c("matrix", "arrary") -- and S3 dispatch Nov 25 Jan Gorecki class(<matrix>) |--> c("matrix", "arrary") -- and S3 dispatch Nov 25 Martin Maechler head.matrix can return 1000s of columns .. Nov 28