makenum | R Documentation |
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.
makenum(x)
x |
a factor with numeric levels |
This function should only be used on factors where all levels are valid numbers that can be coerced into a numeric class.
A numeric
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.
Jared E. Knowles
character
a <- ordered(c(1, 3, '09', 7, 5))
b <- makenum(a)
class(b)
b
a
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.