Learn R Programming

MESS (version 0.4-3)

fac2num: Convert factor to numeric vector

Description

Converts the factor labels to a vector of numeric vectors

Usage

fac2num(x)

Arguments

x
A factor

Value

Returns a numeric vector of the same length as x

Details

Returns a vector of numeric values. Elements in the input factor that cannot be converted to numeric will produce NA.

Examples

Run this code

m1 <- matrix(rep(1, 16), 4)
m2 <- matrix(c(1, 0, .5, .5, 0, 1, .5, .5, .5, .5, 1, .5, .5, .5, .5, 1), 4)
m3 <- matrix(c(1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), 4)
cmd(m1, m1)
cmd(m1, m2)
cmd(m2, m3)

Run the code above in your browser using DataLab