to.dummy: Creating dummy variables

Description Usage Arguments Details Value Note Author(s) References Examples

Description

This function creates a dataset of dummy variables based on an input character vector.

Usage

1

Arguments

x

A character vector

Details

This function transforms a character vector x with c characteristics to a set of c dummy variables whose column names corresponding to these characteristics marked with “_DUMMY”.

Value

A data.frame with dummy variables corresponding to the levels of the input variable.

Note

This function contains code from the authors' package MCI.

Author(s)

Thomas Wieland

References

Greene, W. H. (2012): “Econometric Analysis”. 7th edition. Harlow : Pearson.

Examples

1
2
3
4
5
charvec <- c("Peter", "Paul", "Peter", "Mary", "Peter", "Paul")
# Creates a vector with three names (Peter, Paul, Mary)
to.dummy(charvec)
# Returns a data frame with 3 dummy variables
# (Mary_DUMMY, Paul_DUMMY, Peter_DUMMY)

Example output

  Mary_DUMMY Paul_DUMMY Peter_DUMMY
1          0          0           1
2          0          1           0
3          0          0           1
4          1          0           0
5          0          0           1
6          0          1           0

REAT documentation built on Sept. 5, 2021, 5:18 p.m.