Skip to contents

This function replaces values in a column of a dataframe with a new value.

Usage

replace_values(data, targetColumn, secondaryColumn, string2search)

Arguments

data

The dataframe to modify.

targetColumn

The name of the column to modify.

secondaryColumn

The name of the column to extract values from and replace in targetColumn.

The value to search. It can be the whole string or a part of it.

Value

The modified dataframe.

Examples

data <- data.frame(x = c("a", "b", "c"), y = c("d", "e", "f"))
replace_values(data, "x", "y", "b")
#>   x y
#> 1 a d
#> 2 e e
#> 3 c f