Re: [R] memory-efficient column aggregation of a sparse matrix

2007-02-01 Thread Douglas Bates
On 1/31/07, Jon Stearley [EMAIL PROTECTED] wrote: I need to sum the columns of a sparse matrix according to a factor - ie given a sparse matrix X and a factor fac of length ncol(X), sum the elements by column factors and return the sparse matrix Y of size nrow(X) by nlevels(f). The appended

Re: [R] memory-efficient column aggregation of a sparse matrix

2007-02-01 Thread roger koenker
Doug is right, I think, that this would be easier with full indexing using the matrix.coo classe, if you want to use SparseM. But then the tapply seems to be the way to go. url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics

Re: [R] memory-efficient column aggregation of a sparse matrix

2007-02-01 Thread Jon Stearley
On Feb 1, 2007, at 6:22 AM, Douglas Bates wrote: It turns out that in the sparse matrix code used by the Matrix package the triplet representation allows for duplicate index positions with the convention that the resulting value at a position is the sum of the values of any triplets with

[R] memory-efficient column aggregation of a sparse matrix

2007-01-31 Thread Jon Stearley
I need to sum the columns of a sparse matrix according to a factor - ie given a sparse matrix X and a factor fac of length ncol(X), sum the elements by column factors and return the sparse matrix Y of size nrow(X) by nlevels(f). The appended code does the job, but is unacceptably