Skip to content
Prev 172805 / 398506 Next

dummy variable encoding

manipulate
factors.
data),
text
by
readable
have
know
The only benefit that I can see of using 1/2 instead of 0/1 is fairly 
minor.

If you have cases where there are missing values, and you are working in a 
language that doesn't support NA values for integers (or factors; I'm 
thinking of something like C), then you could encode your genders as

0: not recorded
1: female
2: male

Then you can include logic like

if(gender)
{ 
   do something
}

The alternative encoding of 0/1, would be something like

-1: not recorded
0: female
1: male

This makes the code slightly less pretty.

if(gender != -1)
{ 
   do something
}

Again, none of this really applies to R, since you should be using factors 
for this sort of variable.

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}