R Under development (unstable) (2023-11-05 r85474 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 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 Under development (unstable) (2023-11-05 r85474 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows Server 2022 x64 (build 20348) Matrix products: default 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-3 Matrix_1.6-2 loaded via a namespace (and not attached): [1] compiler_4.4.0 grid_4.4.0 lattice_0.22-5 > packageDescription("Matrix") Package: Matrix Version: 1.6-2 VersionNote: do also bump src/version.h, inst/include/Matrix/version.h Date: 2023-11-03 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, notably CHOLMOD and AMD", "collaborators listed in dir(pattern=\"^[A-Z]+[.]txt$\", full.names=TRUE, system.file(\"doc\", \"SuiteSparse\", package=\"Matrix\"))")), person("Jens", "Oehlschlägel", role = "ctb", comment = "initial nearPD()"), 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("R Core Team", role = "ctb", comment = "base R's matrix implementation")) Depends: R (>= 3.5.0), 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: 2023-11-03 14:36:56 UTC; maechler Author: Douglas Bates [aut] (), Martin Maechler [aut, cre] (), Mikael Jagan [aut] (), Timothy A. Davis [ctb] (, SuiteSparse libraries, notably CHOLMOD and AMD, collaborators listed in dir(pattern="^[A-Z]+[.]txt$", full.names=TRUE, system.file("doc", "SuiteSparse", package="Matrix"))), Jens Oehlschlägel [ctb] (initial nearPD()), Jason Riedy [ctb] (, GNU Octave's condest() and onenormest(), Copyright: Regents of the University of California), R Core Team [ctb] (base R's matrix implementation) Maintainer: Martin Maechler Built: R 4.4.0; x86_64-w64-mingw32; 2023-11-06 08:40:07 UTC; windows Archs: x64 -- File: D:/RCompile/CRANincoming/R-devel/lib/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.65 0.28 1.87