Learn R Programming

Smisc (version 0.3.9.1)

factor2numeric: A simple function for converting factors to numeric values

Description

A simple function for converting factors to numeric values

Usage

factor2numeric(x)

Arguments

x

A vector of type factor

Value

x converted to a numeric vector

Examples

Run this code
# NOT RUN {
# Define a factor object
y <- factor(5:7)
y

# incorrectly convert to numeric
as.numeric(y)

# correctly convert
factor2numeric(y)

# }

Run the code above in your browser using DataLab