Re: [R] Conditional recoding for purpose of imputing

2014-02-10 Thread Yvan Richard
The idea behind the treatment of NAs is that if you don't know what the value is, how do you know if it's 1 or not (in your case)? Therefore, it's normal that the result to your query is NA. First, I guess your command was supposed to be: y <- ifelse(x==1, 'NO', 'YES') Secondly, if you want to igno

Re: [R] Conditional recoding for purpose of imputing

2014-02-09 Thread Bert Gunter
... Well, the syntax is corrected, but it doesn't solve her problem: ifelse() leaves NA's as NA's. "But:, you ask, "what should NA's become?" As the OP does not tell us, we are left to read tea leaves: only the Shadow knows...* Cheers, Bert * The Shadow also knows about ?is.na, which the OP sh

Re: [R] Conditional recoding for purpose of imputing

2014-02-09 Thread Pascal Oettli
Hello Ana, The syntax is: y <- ifelse(x==1, 'YES', 'NO') Hope this helps, Pascal On 10 February 2014 13:03, 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: > > if

Re: [R] Conditional recoding for purpose of imputing

2014-02-09 Thread David Winsemius
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 a

Re: [R] Conditional recoding for purpose of imputing

2014-02-09 Thread Jim Lemon
On 02/10/2014 03: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.

Re: [R] Conditional recoding

2011-02-19 Thread David Winsemius
On Feb 19, 2011, at 5:14 PM, David Winsemius wrote: On Feb 19, 2011, at 4:36 PM, Krishnan Viswanathan wrote: I am trying to recode a variable into another variable and while the package 'car' works well when it is only recoding A into B, I am not sure I can do the same with recoding (A or

Re: [R] Conditional recoding

2011-02-19 Thread David Winsemius
On Feb 19, 2011, at 4:36 PM, Krishnan Viswanathan wrote: I am trying to recode a variable into another variable and while the package 'car' works well when it is only recoding A into B, I am not sure I can do the same with recoding (A or C) into B. If i can use recode please advise on how

Re: [R] conditional recoding a variable

2009-07-02 Thread jim holtman
Should be (I think): (default condition and the use of "|" instead of "||") social$CitizenType<-if(social$CitizenType=="" | social$PrimaryLanguage=="English","US Citizen", social$CitizenType ) On Thu, Jul 2, 2009 at 7:19 AM, jim holtman wrote: > I think you want to use 'ifelse': > > social$Citize

Re: [R] conditional recoding a variable

2009-07-02 Thread jim holtman
I think you want to use 'ifelse': social$CitizenType<-ifelse(social$CitizenType=="" ||social$PrimaryLanguage=="English","US Citizen" ) On Wed, Jul 1, 2009 at 5:45 PM, Chris Anderson wrote: > I have a variable that identifies citizen type but some of my rows are blank. > I want to replace the bla