[R] Data frame modification

siddharth.garg85 at gmail.com siddharth.garg85 at gmail.com
Wed Jul 28 11:30:48 CEST 2010


Hi

I am trying to modify a data frame D with lists x and y in such a way that if a value in x==0 then it should replace that value with the last not zero value in x. I.e.
 
for loop over i{
if(D$x[i]==0)
     D$x[i]=D$x[i-1]
}

The data frame is quite large in size ~ 43000 rows. This operation is taking a large amount of time. Can someone please suggest me what might be the reason.

Thanks
Regards
Siddharth
Sent on my BlackBerry® from Vodafone


More information about the R-help mailing list