Re: [R] Simple question, I think

2009-10-22 Thread Chuck Cleland
On 10/22/2009 12:37 PM, David Kaplan wrote: > Greetings, > > I am recoding a dummy variable (coded 1,0) so that 0 = 2. I am using > the line > > sciach$dummyba[sciach$ba==0] <- 2 > > I notice that it creates a new column dummyba, with 0 coded as 2 but > with 1's now coded as NA. Is there a sim

Re: [R] Simple question, I think

2009-10-22 Thread Kevin E. Thorpe
David Kaplan wrote: Greetings, I am recoding a dummy variable (coded 1,0) so that 0 = 2. I am using the line sciach$dummyba[sciach$ba==0] <- 2 I notice that it creates a new column dummyba, with 0 coded as 2 but with 1's now coded as NA. Is there a simple way around this in the line I am

Re: [R] Simple question, I think

2009-10-22 Thread Henrique Dallazuanna
Use ifelse: sciach$dummyba <- ifelse(sciach$ba == 0, 2, 1) On Thu, Oct 22, 2009 at 2:37 PM, David Kaplan wrote: > Greetings, > > I am recoding a dummy variable (coded 1,0) so that 0 = 2.  I am using the > line > > sciach$dummyba[sciach$ba==0] <- 2 > > I notice that it creates a new column dummyb

[R] Simple question, I think

2009-10-22 Thread David Kaplan
Greetings, I am recoding a dummy variable (coded 1,0) so that 0 = 2. I am using the line sciach$dummyba[sciach$ba==0] <- 2 I notice that it creates a new column dummyba, with 0 coded as 2 but with 1's now coded as NA. Is there a simple way around this in the line I am using, or do I need