dummy: Creating Dummy-Code Columns for Values of a Variable

View source: R/dummy.R

dummyR Documentation

Creating Dummy-Code Columns for Values of a Variable

Description

This function applies dummy-coding to a variable of interest, enabling the creation of n or n-1 columns/variables based on n number of attributes for the variable.

Usage

dummy(df, var, remove = FALSE)

Arguments

df

data frame to read in.

var

the variable to be dummy-coded. Is automatically converted to a character string.

remove

logical (default set to F). When set to remove = T, will return a data frame using the true number of dummy coded columns (e.g. n-1).

Value

This function updates the data frame with new variables (columns) representing unique values of a selected variable, and a binary score (0/1) for the absence or presence of a column's represented value for each observation.

Examples

data <- howell_aids_long

dummy(data, student)

vannstats documentation built on April 15, 2023, 9:09 a.m.