Learn R Programming

softmaxreg (version 1.2)

convertClass2Matrix: Convert A Vector of Factors to Matrix

Description

Convert A Vector of Factors to Matrix

Usage

convertClass2Matrix(target)

Arguments

target
Vector of factor representing each class.

Value

Matrix with dimensions number of observation * number of class factors

Details

This Function can be used to convert factor to matrix yMat, e.g. For type 'raw' softmaxReg function input yMat, softmax regression.

See Also

softmaxReg

Examples

Run this code
## This Function can be used to convert factor to matrix yMat.
## e.g. For type 'raw' softmaxReg function input yMat, softmax regression.
y = as.factor(c(rep(1,50),rep(2,50),rep(3,50)))
yMat = convertClass2Matrix(y)
nObs = dim(yMat)[1]
K = dim(yMat)[2]
nObs
K

Run the code above in your browser using DataLab