[R-sig-Epi] question re: recoding in R
Alexandre Aguiar
asaguiar at spsconsultoria.com
Wed Jul 25 23:37:01 CEST 2007
Em Qua 25 Jul 2007, Lynn Disney escreveu:
> 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 hand variablec=1 and then have variableD
> turned into a 1 when these conditions are true and 0 when any one of
> them are false.
Ooops! This one even I know.
d <- 0
if( a & b & c ) d <- 1
Depending on the expected proportions of d==1 and d==0 and how many tests you
are going to do, starting with d <- 1 and then testing for !( a & b & c )
could be faster. However, the code above should be good enough in 99.9% of
applications.
Maybe you would like to check out [http://finzi.psych.upenn.edu/nmz.html]. It
has answsered 100% of my questions so far.
Best wishes.
Alexandre
--
Alexandre Santos Aguiar, MD
--
website: http://spsconsultoria.com/
Voicemail: +55-11-3717-4866 (SP)
Voicemail: +55-21-3717-4866 (RJ)
Voicemail: +55-11-2157-6891 (SP)
Fax: +55-11-5549-8760 (SP)
--
More information about the R-sig-Epi
mailing list