binaries {lmreg} | R Documentation |
Convert categorical variable to several binary variables
Description
Stacks up in columns the values of all the binary variables that can be associated with different levels of a categorical variable.
Usage
binaries(x)
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
x <- c(1,2,2,3,1,1,2,3,3,2,1)
binaries(x)
binaries(as.factor(x))
[Package lmreg version 1.2 Index]