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

[R] conditional recoding a variable

2009-07-01 Thread Chris Anderson
I have a variable that identifies citizen type but some of my rows are blank. I want to replace the blank entries with the correct value which is conditional on another variable. In SAS, my conditional statement would be as follow: if citizenType="" and primarylanguage="English" then citizenType