R version 4.5.0 alpha (2025-03-25 r88054 ucrt) Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ### So I see things in old saved "R CMD check .." directories > require("Matrix") Loading required package: Matrix > require("MatrixModels") Loading required package: MatrixModels > sessionInfo() R version 4.5.0 alpha (2025-03-25 r88054 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows Server 2022 x64 (build 20348) Matrix products: default LAPACK version 3.12.1 locale: [1] LC_COLLATE=C LC_CTYPE=German_Germany.utf8 [3] LC_MONETARY=C LC_NUMERIC=C [5] LC_TIME=C time zone: Europe/Berlin tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] MatrixModels_0.5-4 Matrix_1.7-3 loaded via a namespace (and not attached): [1] compiler_4.5.0 grid_4.5.0 lattice_0.22-6 > packageDescription("Matrix") Package: Matrix Version: 1.7-3 VersionNote: do also bump src/version.h, inst/include/Matrix/version.h Date: 2025-03-05 Priority: recommended Title: Sparse and Dense Matrix Classes and Methods Description: A rich hierarchy of sparse and dense matrix classes, including general, symmetric, triangular, and diagonal matrices with numeric, logical, or pattern entries. Efficient methods for operating on such matrices, often wrapping the 'BLAS', 'LAPACK', and 'SuiteSparse' libraries. License: GPL (>= 2) | file LICENCE URL: https://Matrix.R-forge.R-project.org BugReports: https://R-forge.R-project.org/tracker/?atid=294&group_id=61 Contact: Matrix-authors@R-project.org Authors@R: c(person("Douglas", "Bates", role = "aut", comment = c(ORCID = "0000-0001-8316-9503")), person("Martin", "Maechler", role = c("aut", "cre"), email = "mmaechler+Matrix@gmail.com", comment = c(ORCID = "0000-0002-8685-9910")), person("Mikael", "Jagan", role = "aut", comment = c(ORCID = "0000-0002-3542-2938")), person("Timothy A.", "Davis", role = "ctb", comment = c(ORCID = "0000-0001-7614-6899", "SuiteSparse libraries", "collaborators listed in dir(system.file(\"doc\", \"SuiteSparse\", package=\"Matrix\"), pattern=\"License\", full.names=TRUE, recursive=TRUE)")), person("George", "Karypis", role = "ctb", comment = c(ORCID = "0000-0003-2753-1437", "METIS library", "Copyright: Regents of the University of Minnesota")), person("Jason", "Riedy", role = "ctb", comment = c(ORCID = "0000-0002-4345-4200", "GNU Octave's condest() and onenormest()", "Copyright: Regents of the University of California")), person("Jens", "Oehlschlägel", role = "ctb", comment = "initial nearPD()"), person("R Core Team", role = "ctb", comment = c(ROR = "02zz1nj61", "base R's matrix implementation"))) Depends: R (>= 4.4), methods Imports: grDevices, graphics, grid, lattice, stats, utils Suggests: MASS, datasets, sfsmisc, tools Enhances: SparseM, graph LazyData: no LazyDataNote: not possible, since we use data/*.R and our S4 classes BuildResaveData: no Encoding: UTF-8 NeedsCompilation: yes Packaged: 2025-03-05 09:59:22 UTC; maechler Author: Douglas Bates [aut] (), Martin Maechler [aut, cre] (), Mikael Jagan [aut] (), Timothy A. Davis [ctb] (, SuiteSparse libraries, collaborators listed in dir(system.file("doc", "SuiteSparse", package="Matrix"), pattern="License", full.names=TRUE, recursive=TRUE)), George Karypis [ctb] (, METIS library, Copyright: Regents of the University of Minnesota), Jason Riedy [ctb] (, GNU Octave's condest() and onenormest(), Copyright: Regents of the University of California), Jens Oehlschlägel [ctb] (initial nearPD()), R Core Team [ctb] (02zz1nj61, base R's matrix implementation) Maintainer: Martin Maechler Repository: CRAN Date/Publication: 2025-03-11 07:20:02 UTC Built: R 4.5.0; x86_64-w64-mingw32; 2025-03-25 23:44:47 UTC; windows Archs: x64 -- File: D:/RCompile/CRANpkg/lib/4.5/Matrix/Meta/package.rds > > ## From: Torsten Hothorn > ## Subject: bug in model.Matrix with contrasts.arg set > ## Date: Mon, 1 Mar 2021 09:34:49 +0100 > > ## MM added stopifnot() and 'sparse = TRUE' > > ### ordered factor > d <- data.frame(x = gl(3, 3, ordered = TRUE)) # 'ordered' ==> default contrasts "contr.poly" > > ### default contrast works > (x <- model.matrix(~ x, data = d)) (Intercept) x.L x.Q 1 1 -7.071068e-01 0.4082483 2 1 -7.071068e-01 0.4082483 3 1 -7.071068e-01 0.4082483 4 1 -7.850462e-17 -0.8164966 5 1 -7.850462e-17 -0.8164966 6 1 -7.850462e-17 -0.8164966 7 1 7.071068e-01 0.4082483 8 1 7.071068e-01 0.4082483 9 1 7.071068e-01 0.4082483 attr(,"assign") [1] 0 1 1 attr(,"contrasts") attr(,"contrasts")$x [1] "contr.poly" > (X <- model.Matrix(~ x, data = d)) "ddenseModelMatrix": 9 x 3 Matrix of class "dgeMatrix" (Intercept) x.L x.Q 1 1 -7.071068e-01 0.4082483 2 1 -7.071068e-01 0.4082483 3 1 -7.071068e-01 0.4082483 4 1 -7.850462e-17 -0.8164966 5 1 -7.850462e-17 -0.8164966 6 1 -7.850462e-17 -0.8164966 7 1 7.071068e-01 0.4082483 8 1 7.071068e-01 0.4082483 9 1 7.071068e-01 0.4082483 @ assign: 0 1 1 @ contrasts: $x [1] "contr.poly" > stopifnot(identical(dim(x), dim(X)), all(X == x)) > > ### other contrasts fail -- MM now fixed > ctr <- list(x = contr.treatment) > (x <- model.matrix(~ x, data = d, contrasts.arg = ctr)) # of course fine (Intercept) x2 x3 1 1 0 0 2 1 0 0 3 1 0 0 4 1 1 0 5 1 1 0 6 1 1 0 7 1 0 1 8 1 0 1 9 1 0 1 attr(,"assign") [1] 0 1 1 attr(,"contrasts") attr(,"contrasts")$x 2 3 1 0 0 2 1 0 3 0 1 > (X <- model.Matrix(~ x, data = d, contrasts.arg = ctr)) "ddenseModelMatrix": 9 x 3 Matrix of class "dgeMatrix" (Intercept) x2 x3 1 1 0 0 2 1 0 0 3 1 0 0 4 1 1 0 5 1 1 0 6 1 1 0 7 1 0 1 8 1 0 1 9 1 0 1 @ assign: 0 1 1 @ contrasts: $x 2 3 1 0 0 2 1 0 3 0 1 > ## gave Error in sprintf(gettext(fmt, domain = domain), ...) : too few arguments > stopifnot(identical(dim(x), dim(X)), all(X == x)) > ## > (x.<- model.matrix(~ x, data = d, contrasts.arg = attr(x, "contrasts"))) (Intercept) x2 x3 1 1 0 0 2 1 0 0 3 1 0 0 4 1 1 0 5 1 1 0 6 1 1 0 7 1 0 1 8 1 0 1 9 1 0 1 attr(,"assign") [1] 0 1 1 attr(,"contrasts") attr(,"contrasts")$x 2 3 1 0 0 2 1 0 3 0 1 > (X <- model.Matrix(~ x, data = d, contrasts.arg = attr(x, "contrasts"))) "ddenseModelMatrix": 9 x 3 Matrix of class "dgeMatrix" (Intercept) x2 x3 1 1 0 0 2 1 0 0 3 1 0 0 4 1 1 0 5 1 1 0 6 1 1 0 7 1 0 1 8 1 0 1 9 1 0 1 @ assign: 0 1 1 @ contrasts: $x 2 3 1 0 0 2 1 0 3 0 1 > (Xs<- model.Matrix(~ x, data = d, contrasts.arg = attr(x, "contrasts"), sparse=TRUE)) "dsparseModelMatrix": 9 x 3 sparse Matrix of class "dgCMatrix" (Intercept) x2 x3 1 1 . . 2 1 . . 3 1 . . 4 1 1 . 5 1 1 . 6 1 1 . 7 1 . 1 8 1 . 1 9 1 . 1 @ assign: 0 1 1 @ contrasts: $x 2 3 1 0 0 2 1 0 3 0 1 > ## gave Error in sprintf(gettext(fmt, domain = domain), ...) : too few arguments > stopifnot(identical(dim(x), dim(X )), all(X == x), + identical(dim(x), dim(Xs)), all(Xs== x), + identical(x, x.)) > > > ctr <- list(x = contr.sum) > (x <- model.matrix(~ x, data = d, contrasts.arg = ctr)) (Intercept) x1 x2 1 1 1 0 2 1 1 0 3 1 1 0 4 1 0 1 5 1 0 1 6 1 0 1 7 1 -1 -1 8 1 -1 -1 9 1 -1 -1 attr(,"assign") [1] 0 1 1 attr(,"contrasts") attr(,"contrasts")$x [,1] [,2] 1 1 0 2 0 1 3 -1 -1 > (X <- model.Matrix(~ x, data = d, contrasts.arg = ctr)) "ddenseModelMatrix": 9 x 3 Matrix of class "dgeMatrix" (Intercept) x1 x2 1 1 1 0 2 1 1 0 3 1 1 0 4 1 0 1 5 1 0 1 6 1 0 1 7 1 -1 -1 8 1 -1 -1 9 1 -1 -1 @ assign: 0 1 1 @ contrasts: $x [,1] [,2] 1 1 0 2 0 1 3 -1 -1 > stopifnot(identical(dim(x), dim(X)), all(X == x)) > ## gave Error in sprintf(gettext(fmt, domain = domain), ...) : too few arguments > (X <- model.Matrix(~ x, data = d, contrasts.arg = attr(x, "contrasts"))) "ddenseModelMatrix": 9 x 3 Matrix of class "dgeMatrix" (Intercept) x1 x2 1 1 1 0 2 1 1 0 3 1 1 0 4 1 0 1 5 1 0 1 6 1 0 1 7 1 -1 -1 8 1 -1 -1 9 1 -1 -1 @ assign: 0 1 1 @ contrasts: $x [,1] [,2] 1 1 0 2 0 1 3 -1 -1 > ## gave Error in sprintf(gettext(fmt, domain = domain), ...) : too few arguments > stopifnot(identical(dim(x), dim(X)), all(X == x)) > > > > proc.time() user system elapsed 1.57 0.12 1.68