[R] IFELSE function XXXX

Ben Bolker bbolker at gmail.com
Wed Apr 6 00:48:50 CEST 2011


William Dunlap <wdunlap <at> tibco.com> writes:

> Avoid assignments in arguments to function calls, especially
> multiple assignments to the same object, except when you know
> what you are doing and want to write obscure code.
> 
> Change the above line to
>   data3$input1 <- ifelse(data3$res1==1, data3$input1+10, data3input1)
> 

  data3 <- transform(data3,input1=ifelse(res==1,input1+10,input1))

 might be even clearer



More information about the R-help mailing list