FactorToNumeric: Convert a factor variable to a numeric vector

View source: R/variable.R

FactorToNumericR Documentation

Convert a factor variable to a numeric vector

Description

Convert a factor variable to a numeric vector (when the factor is ordered), or a matrix of indicator variables (when the factor is not ordered).

Usage

FactorToNumeric(x, binary = TRUE, name = NULL, remove.first = TRUE)

Arguments

x

A factor or ordered factor.

binary

Returns the factor as binary variables. If FALSE, OrderedToNumeric.

name

The name of the variable.

remove.first

Remove the first binary variable, if a binary variable is being created.

Value

a vector of length x, if x is an ordered factor; otherwise, a 0-1 matrix with number of rows equal to the length of x an number of columns equal to the number of levels in x

See Also

model.matrix, AsNumeric, OrderedToNumeric


NumbersInternational/flipTransformations documentation built on Feb. 26, 2024, 6:43 a.m.