Recode value labels based on numeric code
recode_vallab(x, code, new_label)
Arguments
- x
haven_labelled vector to be passed through.
- code
Numeric value that specifies code where value label is to be replaced.
- new_label
Character string to be used as the new value label.
Examples
x <- haven::labelled(c(1,2,3,2,1),c("a" = 1, "b" = 2, "d" = 3))
recode_vallab(x, code = 2, new_label = "Surprise!")
#> <labelled<double>[5]>
#> [1] 1 2 3 2 1
#>
#> Labels:
#> value label
#> 1 a
#> 2 Surprise!
#> 3 d