as.numeric_factor | R Documentation |
Converts a factor with numeric levels to a numeric vector, using the values of the levels.
as.numeric_factor(x, keepNA = FALSE, sortUnique = FALSE)
x |
A factor based on numeric values. |
keepNA |
Keep NA values ( |
sortUnique |
Should the unique character values be sorted? (default = |
A numeric vector with factor levels as names.
f <- factor(round(runif(10,0,9)))
as.numeric_factor(f)
# Add NAs
f <- factor(c(round(runif(9,0,9)),NA))
as.numeric_factor(f)
as.numeric_factor(f, keepNA = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.