categorical.split: Expand all factors into multiple dummy variables whilst...

Description Usage Arguments Value Examples

View source: R/categorical.split.R

Description

Expand all factors (categorical variables) into multiple dummy variables whilst keeping all other variables in the df (if the factor only contains two levels then the factor will be turned into one dummy variable with only 1/0 instead of unnecessary expanding.)

Usage

1
categorical.split(dataframe)

Arguments

dataframe

a data frame containing categorical variables for expansion

Value

A data frame

Examples

1
2
3
4
5
6
7
8
### An example dataset
customers <- data.frame(
  id=c(10,20,30,40,50,60,70),
  gender=c('male','female','female','male','female', 'female', 'male'),
  mood=c('happy','sad','happy','sad','happy', "neutral", "neutral"),
  outcome=c(1,1,0,0,0,0,1))

categorical.split(customers)

nzjessica/treevis documentation built on June 27, 2020, 1:20 a.m.