DUMMY | R Documentation |
Convert categorical variable to dummy (0/1) coding
DUMMY(x, catnames=NA)
x |
Variable (vector) of categorical data to be coded |
catnames |
Category names |
The function DUMMY
takes a categorical variable and converts it to a set of dummy variables (zeros and ones), where the ones indicate the corresponding category. There are as many columns in the result as there are unique categories in the input vector.
Michael Greenacre
# Indicator (dummy) coding of sex in FishMorphology data set
data(fish)
sex <- fish[,1]
sex.Z <- DUMMY(sex, catnames=c("F","M"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.