convertClass2Matrix: Convert A Vector of Factors to Matrix

Description Usage Arguments Details Value See Also Examples

Description

Convert A Vector of Factors to Matrix

Usage

1

Arguments

target

Vector of factor representing each class.

Details

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

Value

Matrix with dimensions number of observation * number of class factors

See Also

softmaxReg

Examples

1
2
3
4
5
6
7
8
## 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

Example output

[1] 150
[1] 3

softmaxreg documentation built on May 2, 2019, 5:22 p.m.