map_to_value | R Documentation |
Map Character Vector to New Values
map_to_value(x, map_assignment, na, other)
x |
Character vector. |
map_assignment |
Vector of new values named with |
other |
The value to map all other values not in |
This function converts x
to factor, recodes the factor, and then
returns the recoded factor vector as character.
A character vector of the same length as x.
## Not run: x <- c('T', 'R', 'H', 'W', 'P', 'NA', NA_character) map_to_value( x = x, map_assignment = c('T' = 'red', 'R' = 'green'), other = 'black' ) map_to_value( x = x, map_assignment = c('T' = 'red', 'R' = 'green', 'NA' = 'white'), other = 'black' ) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.