Given a melted data frame, a list of values as they currently are in the data frame mapped to a list of what you want the values to be, this method will swap the values. Useful for shortening up or cleaning data.
1 | swap_by_value(swap_list, variable, data = get_data())
|
swap_list |
list. A list mapping current values to what they should be.
e.g., to replace all instances of "dog" witih "cat", use
|
variable |
character. The name of the variable where the replacement occurs. |
data. |
The data to be transformed. This is assumed to be a three column melted dataframe, using reshape2 <http://cran.r-project.org/web/packages/reshape2/index.html>. The first column should contain IDs, the second column should contain variable names, and the third column should contain variable values. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.