Learn R Programming

micsr (version 0.1-1)

dummy: 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)

Value

a data frame

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

Examples

Run this code
charitable %>% dummy(religion, education)

Run the code above in your browser using DataLab