Skip to content

Preserve dimnames  #8

@alexpghayes

Description

@alexpghayes

Apparently Matrix should export:

dimScale <- function(x, d1 = 1 / sqrt(diag(x, FALSE)), d2 = d1) {
     dim.x <- dim(x)
     D1 <- Diagonal(n = dim.x[2L], x = d1)
     D2 <- if(missing(d2)) D1 else Diagonal(n = dim.x[1L], x = d2)
     y <- D1 %*% x %*% D2 # inefficient for symmetricMatrix 'x', but "general"
     if(is(x, "symmetricMatrix"))
         y <- forceSymmetric(y, x@uplo)
     y@Dimnames <- dimnames(x)
     y
}

rowScale <- function(x, d) {
     y <- Diagonal(n = nrow(x), x = d) %*% x
     y@Dimnames <- dimnames(x)
     y
}

colScale <- function(x, d) {
     y <- x %*% Diagonal(n = ncol(x), x = d)
     y@Dimnames <- dimnames(x)
     y
}

beginning with version 1.5.2, but I can't install 1.5.3 from CRAN for some reason, and the dev version I just installed with

install.packages("Matrix", repos = "http://r-forge.r-project.org/")

is apparently version 1.5.2 and doesn't appear export dimScale() or friends, so this is a problem for later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions