On Sep 29, 2009, at 5:53 PM, Antonio Paredes wrote:
Hello everyone,
Can somebody give a hint on how to go about speeding the following
loop:
You could try a loop-less approach:
system.time(
targets <- dat$ycon[i]==0 | dat$ytrt[i]==0
dat$ycon[targets]<-dat$ycon[targets]+0.5
da
Hello everyone,
Can somebody give a hint on how to go about speeding the following loop:
system.time(
for(i in 1:nrow(dat)){
if(dat$ycon[i]==0 || dat$ytrt[i]==0)
dat$ycon[i]<-dat$ycon[i]+0.5
dat$ytrt[i]<-dat$ytrt[i]+0.5
dat$cony[i]<-dat$cony[i]+0.5
dat$trty[i]<-dat$trty[i]+0.5
}
2 matches
Mail list logo