Re: [R] column permutation of sparse matrix

2011-12-22 Thread khai
Sorry. I erred somewhere in making the original M1 matrix using sampling call in the spMatrix function. I still don't really understand why the matrix values do not match exactly with M1@x. If I regenerate M1 this way... > i=c(1:5,5:1) > j=c(1:5,2:6) > x=rnorm(10,2) > M1 <- spMatrix(nrow=5,ncol=6

Re: [R] column permutation of sparse matrix

2011-12-21 Thread cberry
Douglas Bates writes: > On Tue, Dec 20, 2011 at 8:20 AM, Jean V Adams wrote: > > Hi Jean, > >> khai wrote on 12/19/2011 11:26:55 PM: >> >>> Hi, >>> >>> I'm very new to working with sparse matrices and would like to know how >> I >>> can column permute a sparse matrix. Here is a small example: >>

Re: [R] column permutation of sparse matrix

2011-12-20 Thread Jean V Adams
khai wrote on 12/20/2011 01:24:10 PM: > Thanks very much for responses. The 2 suggestions each do a part of what I > want. Jean's proposal permutes nonzero elements within each row but shifts > the location of the nonzero element around in the j slot of each i row. And > Douglas's idea keeps th

Re: [R] column permutation of sparse matrix

2011-12-20 Thread khai
Thanks very much for responses. The 2 suggestions each do a part of what I want. Jean's proposal permutes nonzero elements within each row but shifts the location of the nonzero element around in the j slot of each i row. And Douglas's idea keeps the second part but permutes the entire x slot valu

Re: [R] column permutation of sparse matrix

2011-12-20 Thread Douglas Bates
On Tue, Dec 20, 2011 at 8:20 AM, Jean V Adams wrote: Hi Jean, > khai wrote on 12/19/2011 11:26:55 PM: > >> Hi, >> >> I'm very new to working with sparse matrices and would like to know how > I >> can column permute a sparse matrix. Here is a small example: >> >> > M1 <- >> > spMatrix(nrow=5,ncol

Re: [R] column permutation of sparse matrix

2011-12-20 Thread Jean V Adams
khai wrote on 12/19/2011 11:26:55 PM: > Hi, > > I'm very new to working with sparse matrices and would like to know how I > can column permute a sparse matrix. Here is a small example: > > > M1 <- > > spMatrix(nrow=5,ncol=6,i=sample(5,15,replace=TRUE),j=sample(6, > 15,replace=TRUE),x=round_any

[R] column permutation of sparse matrix

2011-12-19 Thread khai
Hi, I'm very new to working with sparse matrices and would like to know how I can column permute a sparse matrix. Here is a small example: > M1 <- > spMatrix(nrow=5,ncol=6,i=sample(5,15,replace=TRUE),j=sample(6,15,replace=TRUE),x=round_any(rnorm(15,2),0.001)) > M1 5 x 6 sparse Matrix of class "d