Factor2Binary: easily convert a k-level factor variable to k binary...

Description Usage Arguments Value Examples

View source: R/Mfx_functions.R

Description

easily convert a k-level factor variable to k binary variables

Usage

1

Arguments

y

a factor variable with at least 2 levels

Value

a matrix of k binary columns, one corresponding to each level of the input, y

Examples

1
2
3
4
5
6
7
my_factor <- c("bob", "sharron", "bob", "alice", "alice")

my_factor <- as.factor(my_factor)

my_binary_matrix <- Factor2Binary(my_factor)

my_binary_matrix

TommyJones/marginal documentation built on Nov. 21, 2019, 3:53 p.m.