Hello,

I'm working with a very large, very sparse X matrix. Let csr.X <- *
as.matrix.csr*(X) as described by the SparseM package.


The documentation says that "Indexing .... work just like they do on dense
matrices". To me this says that I should be able to perform operations on
the rows of csr.X in the same way I would on X itself. E.g.
f <- function(x){
  for (i in 1:n){
    u[i] <- log(1+exp(t(X[i,])%*%beta))
  }
  sm <- sum(u)
  return(sm)
}

However, csr.X[i,] doesn't exist.
Now I get how *as.matrix.csr* coerces X into an object with three arrays,
two indexes and a list of the non-zero data. What I can't quite wrap my
brain around is how I would go about using those indices to perform
iterative operations on the rows of X, for example in my toy function
above.

I'm hoping that someone with more experience working with sparse matrices
can provide a few suggestions or pointers? I'm not hooked on this package
either, it was just the first one I came across via Rseek.


Many thanks,
-Robin

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to