[R] memory management uestion [Broadcast]
Liaw, Andy
andy_liaw at merck.com
Tue Feb 20 14:30:43 CET 2007
I don't see why making copies of the columns you need inside the loop is
"better" memory management. If the data are in a matrix, accessing
elements is quite fast. If you're worrying about speed of that, do what
Charles suggest: work with the transpose so that you are accessing
elements in the same column in each iteration of the loop.
Andy
From: Federico Calboli
>
> Charles C. Berry wrote:
>
> > Whoa! You are accessing one ROW at a time.
> >
> > Either way this will tangle up your cache if you have many rows and
> > columns in your orignal data.
> >
> > You might do better to do
> >
> > Y <- t( X ) ### use '<-' !
> >
> > for (i in whatever ){
> > do something using Y[ , i ]
> > }
>
> My question is NOT how to write the fastest code, it is
> whether dummy variables (for lack of better words) make the
> memory management better, i.e. faster, or not.
>
> Best,
>
> Fede
>
> --
> Federico C. F. Calboli
> Department of Epidemiology and Public Health Imperial
> College, St Mary's Campus Norfolk Place, London W2 1PG
>
> Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193
>
> f.calboli [.a.t] imperial.ac.uk
> f.calboli [.a.t] gmail.com
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>
>
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments,...{{dropped}}
More information about the R-help
mailing list