Replace all occurrences of a value in a vector and replace
Arguments
- vec
Vector
- find
Value to replace
- replace
Replacement value
- n_max
Maximum number of replacements (starting at index 1)
Examples
c(1,1,3,6,6,7,9) |> replace_in_vector(find=6, replace=5)
#> [1] 1 1 3 5 5 7 9