as_numeric_factor: Factor to numeric via character

Description Usage Arguments Examples

View source: R/as_numeric_factor.R

Description

Shorthand to avoid the all-to-common bug of going straight from factor to numeric.

Usage

1

Arguments

x

factor to be converted to numeric

Examples

1
2
3
4
5
6
7
year = factor(1998:2004)
# bad
as.numeric(year)
# good
as.numeric(as.character(year))
# not much less typing, but no nesting (and it will auto-complete)
as_numeric_factor(year)

gregorp/gregor documentation built on May 17, 2019, 8:36 a.m.