----- Forwarded Message ----
From: Nnamdi <nnamdii at yahoo.com>
To: roger koenker <rkoenker at uiuc.edu>
Sent: Friday, April 18, 2008 1:08:58 PM
Subject: Re: [R] efficiently replacing values in a matrix
I tried the sparse matrix implementation, still there are issues:
a <- matrix(nrow=10000,ncol=10000)> a.csr <- as.matrix.csr(a)
Error in if (nnz == 0) { : missing value where TRUE/FALSE needed
I'm guessing this error here is because 'a' matrix is initialized
with'NA's. Yet when I try initializing 'a' matrix with 0s I
get:> a<-matrix(nrow=10000,ncol=10000,rep(0,10000*10000))
Error: cannot allocate vector of size 762.9 Mb
Either way I cannot achieve my goal of being able to efficiently enter values
into this matrix.
To answer your previous question, this matrix is somewhat dense. It is a
symmetrical matrix thus only the upper triangle is filled.
Any other ideas? Thanks again
--Nnamdi
----- Original Message ----
From: roger koenker <rkoenker at uiuc.edu>
To: Nnamdi <nnamdii at yahoo.com>
Sent: Friday, April 18, 2008 12:25:54 PM
Subject: Re: [R] efficiently replacing values in a matrix
is this really a dense matrix? if not, then sparse representations
would be much more efficient...
url: www.econ.uiuc.edu/~roger Roger Koenker
email rkoenker at uiuc.edu Department of Economics
vox: 217-333-4558 University of Illinois
fax: 217-244-6678 Champaign, IL 61820
On Apr 18, 2008, at 12:11 PM, Nnamdi wrote:
>
> Still it is pretty slow when entering values into a large matrix.
> Case in
> point:
>
>> a <- matrix(nrow=10000,ncol=10000)
>> system.time(a[1,1] <- 1903908.80385)
> user system elapsed
> 30.840 6.226 41.416
>> is.matrix(a)
> [1] TRUE
>
> Is there a better way to enter values into large matrices? If I have
> to
> spend 41 secs each time I enter into a cell and I have 10000x10000
> cells to
> enter that is impractical!
>
> --Nnamdi
>
> Rolf Turner-3 wrote:
>>
>>
>> On 17/04/2008, at 9:33 AM, Charles C. Berry wrote:
>>
>> <snip>
>>
>>> I'll lay odds that Matthew's 'matrix' is actually a
data.frame, and
>>> I'll not be surprised if the columns are factors.
>>
>> <snip>
>>
>> I suspect that you're right.
>>
>> ***Why*** can't people distinguish between data frames and
matrices?
>> If they were the same <expletive deleted> thing, there
wouldn't be
>> two
>> different terms for them, would there?
>>
>> cheers,
>>
>> Rolf Turner
>>
>> ######################################################################
>> Attention:\ This e-mail message is privileged and confid...
>> {{dropped:9}}
>>
>> ______________________________________________
>> R-help at 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.
>>
>>
>
> --
> View this message in context:
http://www.nabble.com/efficiently-replacing-values-in-a-matrix-tp16732795p16763578.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
____________________________________________________________________________________
Be a better friend, newshound, and
____________________________________________________________________________________
Be a better friend, newshound, and