[R-sig-Epi] question re: recoding in R

griera at gmail.com griera at gmail.com
Thu Jul 26 08:46:12 CEST 2007


A Dimecres 25 Juliol 2007 21:34, Lynn Disney va escriure:
> I need to create dummy variables, for an ID when 3 conditions exist. I
> am having problems figuring out how to do this. For example, I want
> variablea=1 and variableb=1 and variablec=1 and then have variableD
> turned into a 1 when these conditions are true and 0 when any one of
> them are false.

My easy way with a variable (YEAR) with 5 values (2002-2006):

any2002 <- ifelse(YEAR==2002,1,0)
any2003 <- ifelse(YEAR==2003,1,0)
any2004 <- ifelse(YEAR==2004,1,0)
any2005 <- ifelse(YEAR==2005,1,0)
any2006 <- ifelse(YEAR==2006,1,0)

Regards



>
>
>
> Suggestions?
>
>
>
> Lynn D. Disney, Ph.D., J.D., M.P.H.
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Epi at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-epi

-- 


"Coda vez más el periodismo es un invertario de obviedades y de chismes"
José Vidal-Beneyto, La derechización del mundo / 4, El Pais 21-04-07 pag 8



More information about the R-sig-Epi mailing list