dummy_all: Creates an indicador variable for each category of the...

Description Usage Arguments Value Examples

View source: R/library neale.R

Description

This function creates an indicador variable for each category of the selected variables that belong to classes factor or character. Variables are selected using a regular expression. The user can choose to keep all categories or to drop the reference category. The new indicathor variables are named with the category label/value - only alpha-numerical characters are kept, and all accents are removed. Empty categories (i.e. factor levels that are defined but not used) are dropped.

Usage

1
dummy_all(df = NULL, reg.exp = NULL, keep_all = TRUE)

Arguments

df

The dataframe containing the variables to be recoded.

reg.exp

A regular expression identifying the variables that should be analysed.

keep_all

If TRUE, then for every category a dummy variable will be created. If FALSE then the reference category will be dropped.

Value

A (dataframe) contaning only the dummy variables that were created.

Examples

1
df.dummies <- dummy_all(df,reg.exp='^P[0-9]+$',keep_all=TRUE)

neale-eldash/neale documentation built on May 23, 2019, 1:29 p.m.