[R] vectorising ifelse()

Federico Calboli f.calboli at imperial.ac.uk
Fri Jul 22 23:57:10 CEST 2005


On 22 Jul 2005, at 11:20, Adaikalavan Ramasamy wrote:


> Does either 'zippo' or 'zappo' contain the values 1 or 2 ?
>
>
> If so, then you cannot vectorize this code because you are changing  
> the
> values in 'new' at every iteration and potentially sampling a value  
> from
> new[ ,1] or new[ ,2] .
>

That's exactly my situation, and is exactly what I want to do.

After taking out the typo (and bug) "drow[i]>0" the code seems to  
work fast enough... I'll tinker a bit with it, but it could be good  
enough as it is.

Cheers,

Federico Calboli


--
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com




More information about the R-help mailing list