binaries: Convert categorical variable to several binary variables

Description Usage Arguments Details Value Author(s) References Examples

View source: R/binaries.R

Description

Stacks up in columns the values of all the binary variables that can be associated with different levels of a categorical variable.

Usage

1

Arguments

x

A categorical variable (either numeric or character).

Details

The name of each new variable is of the type v.x, where x is the level of the categorical variable for which this binary variable is equal to 1.

Value

A set of binary vectors, each having the value 1 for a unique level of x.

Author(s)

Debasis Sengupta <shairiksengupta@gmail.com>, Jinwen Qiu <qjwsnow_ctw@hotmail.com>

References

Sengupta and Jammalamadaka (2019), Linear Models and Regression with R: An Integrated Approach.

Examples

1
2
3
x <- c(1,2,2,3,1,1,2,3,3,2,1)
binaries(x)
binaries(as.factor(x))

lmreg documentation built on May 2, 2019, 9:29 a.m.

Related to binaries in lmreg...