Learn R Programming

MultBiplotR (version 23.11.0)

Fact2Bin: Converts a Factor into its indicator matrix

Description

Converts a factor into a binary matrix with as many columns as categories of the factor

Usage

Factor2Binary(y, Name = NULL)

Value

An indicator binary matrix

Arguments

y

A factor

Name

Name to use in the final matrix

Author

Jose Luis Vicente Villardon

Examples

Run this code
y=factor(c(1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1))
Factor2Binary(y)

Run the code above in your browser using DataLab