dummy: Convert a single variable of multiple levels into binary...

Description Usage Arguments Details Examples

Description

dummy(dataframe,variable,drop=NULL)

Usage

1
dummy(dataframe, variable, abbrev = TRUE)

Arguments

dataframe

name of the data frame

variable

either the name of the variable in inverted commas or column index

abbrev

logical whether the factor levels should be abbreviated too

Details

Will convert a variable with n levels to n dummy variables appended as columns to the data frame, each comprising 0s and 1s. The variable can be passed as either the name of the variable in inverted commas or the column number. The new variable names will be an abbreviated form of the original variable with an underscore and then the suffix of the original factor level (with the option to abbreviate). One of the levels may not be required in, say, a linear model since it will be represented by the intercept.

Examples

1
dummy(mtcars[,1:2],"cyl")

helophilus/ColsTools documentation built on May 30, 2019, 4:03 p.m.