Description Usage Arguments Value Examples
Relabel factors using a named vector
1 | lkp_to_factor(x, lkp_vals, ..., check_names = TRUE)
|
x |
a character or factor vector to modify |
lkp_vals |
either a named vector where the names are the values in x and the values are the new levels or a character vector defining the order of the values of x. |
... |
additional parameters passed to |
check_names |
check that all the names exist |
a factor
1 2 3 4 5 6 7 | x <- c("apple", "bear", "banana", "dear")
# new value is "fruit"
levels <- c("apple" = "fruit", "banana" = "fruit")
lkp_to_factor(x, levels)
# just reorder factors
lkp_to_factor(x, c("dear", "banana", "apple", "bear"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.