[R] Another Loop

David Winsemius dwinsemius at comcast.net
Wed Sep 30 00:11:39 CEST 2009


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
>    dat$ytrt[targets]<-dat$ytrt[targets]+0.5
>    dat$cony[targets]<-dat$cony[targets]+0.5
>    dat$trty[targets]<-dat$trty[targets]+0.5
>             )
>
>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list