NA)recode(num_vec, `2` =20L, `4` =40L)#> [1] 1 20 3 40 NAcase_match(num_vec,2~20,4~40, .default = num_vec)#> [1] 1 20 3 40 NA# `case_match()` doesn't have the ability to match by position like# `recode()` does
Please do this in all future questions, and even for this question. Without this sample of your data, I can only guess that the values are not character, they are numeric, and should not be enclosed in quotes. But also please keep in mind that what @Tom said, you haven't told us ...