# NOT RUN {
# }
# NOT RUN {
S <- diag.spam(4)
R <- as.dgRMatrix.spam( S)
C <- as.dgCMatrix.spam( S)
as.spam.dgCMatrix(C)
slotNames(U)
slotNames(R)
# For column oriented sparse formats a transpose does not the job,
# as the slot names change.
# as.spam(R) does not work.
# }
# NOT RUN {
# }
# NOT RUN {
# for transformations between SparseM and spam:
as.matrix.csr.spam <- function(x,...) {
newx <- new("matrix.csr")
slot(newx,"ra",check=FALSE) <- x@entries
slot(newx,"ja",check=FALSE) <- x@colindices
slot(newx,"ia",check=FALSE) <- x@rowpointers
slot(newx,"dimension",check=FALSE) <- x@dimension
return(newx)
}
U <- as.matrix.csr.spam( S)
# }
# NOT RUN {
# }
# NOT RUN {
# a dataset contained in Matrix
data(KNex)
as.spam.dgCMatrix(KNex$mm)
# }
Run the code above in your browser using DataLab