[R] Conditional recoding for purpose of imputing
David Winsemius
dwinsemius at comcast.net
Mon Feb 10 05:52:27 CET 2014
On Feb 9, 2014, at 8:03 PM, Ana Genkova wrote:
> Hello,
>
> I am trying the ifelse command for imputing a variable based on a
> conditional statement, but the NAs do not transform. The code I am trying
> is:
>
> ifelse (x==1, y=="NO", y=="YES"). However, the number of NAs remains the
> same after the attempt. I would like to turn all Y (NAs included) into a
> "YES" or a "NO".
The "==" has no place in the second and third arguments to ifelse . It should probably be:
y <- ifelse (x==1, "NO", "YES")
(And do note that "==" is not an assignment operator in any context.)
--
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list