Skip to contents

Replace all occurrences of a value in a vector and replace

Usage

replace_in_vector(vec, find, replace, n_max = Inf)

Arguments

vec

Vector

find

Value to replace

replace

Replacement value

n_max

Maximum number of replacements (starting at index 1)

Value

Vector with values replaced

Examples

c(1,1,3,6,6,7,9) |> replace_in_vector(find=6, replace=5)
#> [1] 1 1 3 5 5 7 9