DUMMY: Dummy variable (indicator) coding

Description Usage Arguments Details Author(s) Examples

View source: R/DUMMY.r

Description

Convert categorical variable to dummy (0/1) coding

Usage

1
DUMMY(x, catnames=NA)

Arguments

x

Variable (vector) of categorical data to be coded

catnames

Category names

Details

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.

Author(s)

Michael Greenacre

Examples

1
2
3
4
# Indicator (dummy) coding of sex in FishMorphology data set
data(fish)
sex   <- fish[,1]
sex.Z <- DUMMY(sex, catnames=c("F","M")) 

Example output

Loading required package: ca
Loading required package: vegan
Loading required package: permute
Loading required package: lattice
This is vegan 2.5-7
Loading required package: ellipse

Attaching package:ellipseThe following object is masked frompackage:graphics:

    pairs

easyCODA documentation built on Sept. 20, 2020, 1:07 a.m.