Re: [R] Slow indexing access for Matrix

2009-02-23 Thread Peter Dalgaard
Niels Richard Hansen wrote: Consider the following little "benchmark" > require(Matrix) > tmp <- Matrix(c(rep(1,1000),rep(0,9000)),ncol=1) > ind <- sample(1:1,1) > system.time(tmp[ind,]) user system elapsed 0.004 0.001 0.005 > ind <- sample(1:1000,1,replace=TRUE) > s

[R] Slow indexing access for Matrix

2009-02-23 Thread Niels Richard Hansen
Consider the following little "benchmark" > require(Matrix) > tmp <- Matrix(c(rep(1,1000),rep(0,9000)),ncol=1) > ind <- sample(1:1,1) > system.time(tmp[ind,]) user system elapsed 0.004 0.001 0.005 > ind <- sample(1:1000,1,replace=TRUE) > system.time(tmp[ind,]) user syst