Skip to content
Prev 229035 / 398500 Next

Data frame modification

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