dummy: Transform a factor in a set of dummy variables

dummyR Documentation

Transform a factor in a set of dummy variables

Description

The normal way to store cathegorical variables in R is to use factors, each modality being a level of this factor. Sometimes however, is is more convenient to use a set of dummy variables.

Usage

dummy(x, ..., keep = FALSE, prefix = NULL, ref = FALSE)

Arguments

x

a data frame

...

series of the data frame, should be factors

keep

a boolean, if TRUE, the original series is kept in the data frame,

prefix

an optional prefix for the names of the computed dummies,

ref

a boolean, if TRUE, a dummy is created for all the levels, including the reference level

Value

a data frame

Examples

charitable %>% dummy(religion, education)

micsr documentation built on May 29, 2024, 7:32 a.m.