arrays and matrices have a numeric dims attribute, vectors don't. If statements lead to bad code.
Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Nov 15, 2019 at 1:19 PM Abby Spurdle <spurdl...@gmail.com> wrote: > > > And indeed I think you are right on spot and this would mean > > > that indeed the implicit class > > > "matrix" should rather become c("matrix", "array"). > > > > 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'm not enthusiastic about matrices extending arrays. > If a matrix is an array, then shouldn't all vectors in R, be arrays too? > > > #mockup > > class (1) > [1] "numeric" "array" > > Which is a bad idea. > It contradicts the central principle that R uses "Vectors" rather than > "Arrays". > And I feel that matrices are and should be, a special case of vectors. > (With their inheritance from vectors taking precedence over anything else). > > If the motivation is to solve the problem of 2D arrays, automatically > being mapped to matrices: > > > class (array (1, c (2, 2) ) ) > [1] "matrix" > > Then wouldn't it be better, to treat 2D arrays, as a special case, and > leave matrices as they are? > > > #mockup > > class (array (1, c (2, 2) ) ) > [1] "array2d" "matrix" "array" > > Then 2D arrays would have access to both matrix and array methods... > > Note, I don't want to enter into (another) discussion on the > differences between implicit class and classes defined via a class > attribute. > That's another discussion, which has little to do with my points above. > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel