Learn R Programming

mvdalab (version 1.7)

my.dummy.df: Create a Design Matrix with the Desired Constrasts

Description

This function generates a dummy variable data frame in support various functions.

Usage

my.dummy.df(data, contr = "contr.niets")

Value

For datasets with categorical variables it produces the specified design matrix.

Arguments

data

a data frame

contr

an optional list. See the contrasts.arg of model.matrix.default.

Author

Nelson Lee Afanador (nelson.afanador@mvdalab.com)

Details

my.dummy.df takes a data.frame with categorical variables, and returns a data.frame in which all the categorical variables columns are expanded as dummy variables.

The argument contr is passed to the default contr.niets; contr.helmert, contr.poly, contr.sum, contr.treatment are also supported.

Examples

Run this code
data(iris)
my.dummy.df(iris)

Run the code above in your browser using DataLab