makenum: a function to convert numeric factors into numeric class...

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/destring.R

Description

This function allows you to convert directly from a numeric factor to the numeric class in R and strip away the underlying level index of a factor. This makes it safer to convert from factors to numeric characters directly without accidentally misassigning numbers.

Usage

1

Arguments

x

a factor with numeric levels

Details

This function should only be used on factors where all levels are valid numbers that can be coerced into a numeric class.

Value

A numeric

Note

This will force all levels to be converted to characters and then to numeric objects. Leading zeroes will be stripped off and commas will cause errors.

Author(s)

Jared E. Knowles

See Also

character

Examples

1
2
3
4
5
a <- ordered(c(1, 3, '09', 7, 5))
b <- makenum(a)
class(b)
b
a

eeptools documentation built on May 3, 2020, 1:05 a.m.