I have posted this message on r-lang, but it is perhaps more appropriate on r-devel:
--- Hello, I'm puzzled by a problem with call to diag(), rowSums(), rownames() on objects of class "dgtMatrix", created by sparseMatrix() or spMatrix(). I use Matrix 0.999375-30. The weird thing is that I don't encounter any problem when I use this functions on the R prompt, or source()-ing a script file; I encounter problems when the code is in a package, installed with R CMD INSTALL, and loaded with library(). I have tried to reduce the package to the bare minimum in order to discover the problem, but it continue even when reduced up to a single method, no dependency other than Matrix. The method is defined as: --- getAdjacentAsSparseMatrix <- function() { adjacents <- sparseMatrix(i=1:10, j=1:10, x=1:10) print(class(adjacents)); diagonal <- as.vector(diag(adjacents)); if (any(diagonal != 0)) { diagonal[diagonal > 1] <- 1; diag(adjacents) <- diagonal; } return(adjacents); } --- And the Depends field in ./DESCRIPTION : --- Depends: R (>= 2.5.0), Matrix --- I have this outputs: [1] "dgTMatrix" Erreur dans y[1L + 0L:(m - 1L) * (n + 1L)] <- x : types (de S4 a double) incompatibles dans l'ajustement d'affectation de type > traceback() 3: diag(adjacents) 2: as.vector(diag(adjacents)) 1: getAdjacentAsSparseMatrix(white3) The same thing happens with the method rowSums(), colnames() and rownames(). In brief, it looks as if the generic functions were called, and not the overloaded ones. I can't figure out how to fix that, and will be interested in any pointers. Best, Sylvain ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel