Renames values within a dataframe based on ids. Useful for imputation.
1 | swap_by_ids(df, variable, swap_list, idname = "id")
|
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 ids to the desired value for that id.
e.g., to replace the value for id #233 with "cat", use
|
idname |
character. The name of the column with ids. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.