swap_by_value: Renames values within a dataframe based on a list of swaps to...

Description Usage Arguments

View source: R/swap_by_value.R

Description

Renames values within a dataframe based on a list of swaps to make. Useful for imputation.

Usage

1
swap_by_value(df, variable, swap_list, grep = FALSE)

Arguments

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 list('dog' = 'cat')

grep

logical. Should values be searched by grep (grep = TRUE) or just found by full name (default)?


peterhurford/surveytools2 documentation built on Feb. 18, 2021, 9:13 p.m.