factor.as.numeric: convert a factor vector to a numeric vector

Description Usage Arguments Examples

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

Description

factor.as.numeric intuitively converts a factor vector of numbers to real numbers and not factors. This is typically an issue when there are repeating numbers in a vector or data frame and base R automatically categorizes them as factors.

Usage

1

Arguments

x

Examples

1
2
3
4
5
6
7
8
yourVector <- as.factor(c(1,1,2,2,4,4,4,5,5,5,5))

# this will not work intuitively for numbers
# mistakenly categorized as factors.
as.numeric(yourVector)

# use this instead.
factor.as.numeric(yourVector)

gnapham/shortcuts documentation built on May 23, 2019, 1:26 p.m.