Re: [R] efficiently replacing values in a matrix

From: Nnamdi <nnamdii_at_yahoo.com>
Date: Fri, 18 Apr 2008 10:11:08 -0700 (PDT)

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.
Received on Fri 18 Apr 2008 - 17:22:22 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 18 Apr 2008 - 20:30:47 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive