Dear All and Mark,

Given a dataset that I have called dat, I was hoping to speed up the
following loop:

for(i in 1:835353){
for(j in 1:86){
if  (is.na(dat[i,j])==TRUE){dat[i,j]<-0 }}}
Actually I am also having a memory problem.  I get the following:

Error: cannot allocate vector of size 3.2 Mb
In addition: Warning messages:
1: In dat[i, j] <- 0 :
  Reached total allocation of 1535Mb: see help(memory.size)
2: In dat[i, j] <- 0 :
  Reached total allocation of 1535Mb: see help(memory.size)
3: In dat[i, j] <- 0 :
  Reached total allocation of 1535Mb: see help(memory.size)
4: In dat[i, j] <- 0 :
  Reached total allocation of 1535Mb: see help(memory.size)

If I try and apply the loop just to a particular column, rather than the
whole dataset, so that I dont have the memory problem, ie

for(i in 1:835353){
if  (is.na(dat[i,4])==TRUE){dat[i,4]<-0 }}

it takes ridiculously long to process, so I was hoping that there would be a
quicker way to do this.

Thank you all very much for the help,
Denise

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to