[R] memory management uestion

Federico Calboli f.calboli at imperial.ac.uk
Mon Feb 19 19:08:59 CET 2007


Hi All,

I would like to ask the following.

I have an array of data in an objetct, let's say X.

I need to use a for loop on the elements of one or more columns of X and I am 
having a debate with a colleague about the best memory management.

I believe that if I do:

col1 = X[,1]
col2 = X[,2]
...
colx = X[,x]


and then

for(i in whatever){
do something using col1[i], col2[i] ... colx[i]
}

my memory management is better that doing:

for(i in whatever){
do something using X[i,1], X[i,2] ... X[,x]
}

BTW, here I *have to* use a for() loop an no nifty tapply, lapply and family.

Any comment is welcome.

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



More information about the R-help mailing list