Re: [R] IFELSE function XXXX

From: Ben Bolker <bbolker_at_gmail.com>
Date: Tue, 05 Apr 2011 22:48:50 +0000

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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 05 Apr 2011 - 22:54:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 05 Apr 2011 - 23:40:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive