swap_by_value: Given a melted data frame, a list of values as they currently...

Description Usage Arguments

Description

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.

Usage

1
swap_by_value(swap_list, variable, data = get_data())

Arguments

swap_list

list. A list mapping current values to what they should be. e.g., to replace all instances of "dog" witih "cat", use list('dog' = 'cat')

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.


peterhurford/surveytools documentation built on May 25, 2019, 1:51 a.m.