SciencesPo (version 1.3.8)

dummy: Generate dummy variables

Description

Provides an alternative to generate dummy variables

Usage

dummy(x, data = NULL, drop = TRUE)

Arguments

x
a column position to generate dummies
data
the data object as a data.frame
drop
A logical value. If TRUE, unused levels will be omitted

encoding

UTF-8

Details

A matrix object

Examples

Run this code
df <- data.frame(y = rnorm(25), x = runif(25,0,1), sex = sample(1:2, 25, rep=TRUE))

dummy(df$sex)

Run the code above in your browser using DataLab