Skip to content
Prev 57700 / 63421 Next

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

> I agree that we can be careful and narrow and still see a
    > nice improvement in behavior. While Herve's point is valid
    > and I understand his frustration, I think staying within
    > the matrix vs c(matrix, array) space is the right scope
    > for this work in terms of fiddling with inheritance.

 [.................]
[................]
I've made up my mind (and not been contradicted by my fellow R
corers) to try go there for  R 4.0.0   next April.

I've found the few places in base R that needed a change (to
pass 'make check-all' in the R sources) and found that indeed a
overzealous check in 'Matrix' needed also a change (a place
where the checking code assume  class(<matrix>) |--> "matrix" ).

There are certainly many more package (codes and checks) that
need adaption .. i.e., should be changed rather *before* the
above change is activated in R-devel (and then will affect all CRAN
and Bioconductor checks.)

To this end, I've published an  'R Blog' yesterday,

   http://bit.ly/R_blog_class_think_2x

which translates to

   https://developer.r-project.org/Blog/public/2019/11/09/when-you-think-class.-think-again/index.html

notably mentioning why using  class(x) == "...."  (or '!=')  or
switch(class(.) ...)  is quite unsafe and hence bad and you
should very often not replace  class(x)  by  class(x)[1]  but
really use the "only truly correct" ;-)

     inherits(x,  "...")
or
     is(x,  "....")   # if you're advanced/brave enough (:-) to
     	    	      # use formal classes (S4)
     
Martin Maechler
ETH Zurich and R Core Team

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