factor.as.numeric: Coerce Factor Labels to Numeric

View source: R/factor.as.numeric.R

factor.as.numericR Documentation

Coerce Factor Labels to Numeric

Description

Coerces a factor to a numeric vector based on the labels for the factor levels (rather than the integer codes assigned to them); e.g., factor level "3.5" becomes a value of 3.5. Labels that cannot be coerced to numeric are treated as NA.

Usage

factor.as.numeric(x)

Arguments

x

factor variable whose labels should be coerced to numeric.

Value

numeric vector.

Examples

my.factor <- as.factor(c(1,2.5,10))
factor.as.numeric(my.factor)
# compare to:
as.numeric(my.factor)

sfraundorf/psycholing documentation built on April 23, 2022, 2:50 a.m.