dummify_data: Dummify Design Matrix

View source: R/bart_package_data_preprocessing.R

dummify_dataR Documentation

Dummify Design Matrix

Description

Create a data frame with factors converted to dummies.

Usage

dummify_data(data)

Arguments

data

Data frame to be dummified.

Details

The column names of the dummy variables are given by the “FactorName_LevelName” and are augmented to the end of the design matrix. See the example below.

Value

Returns a data frame with factors converted to dummy indicator variables.

Note

BART handles dummification internally. This function is provided as a utility function.

Author(s)

Adam Kapelner and Justin Bleich

Examples

## Not run: 
#generate data
set.seed(11)
x1 = rnorm(20)
x2 = as.factor(ifelse(x1 > 0, "A", "B"))
x3 = runif(20)
X = data.frame(x1,x2,x3)
#dummify data
X_dummified = dummify_data(X)
print(X_dummified)

## End(Not run)

bartMachine documentation built on July 9, 2023, 5:59 p.m.