View source: R/swap_by_value.R
Renames values within a dataframe based on a list of swaps to make. Useful for imputation.
1 | swap_by_value(df, variable, swap_list, grep = FALSE)
|
df |
data frame. The data to be transformed. |
variable |
character. The name of the variable in df where the replacement occurs. |
swap_list |
list. A list mapping current values to what they should be.
e.g., to replace all instances of "dog" with "cat", use
|
grep |
logical. Should values be searched by grep (grep = TRUE) or just found by full name (default)? |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.