16.2 Coding
16.2.1 rec()
sjmisc
https://strengejacke.github.io/sjmisc/articles/recodingvariables.html
efc$burden <- rec(
efc$neg_c_7,
rec = c("min:9=1 [low]; 10:12=2 [moderate]; 13:max=3 [high]; else=NA"),
var.label = "Subjective burden",
as.num = FALSE # we want a factor
)
# print frequencies
frq(efc$burden)
#>
#> Subjective burden (x) <categorical>
#> # total N=908 valid N=892 mean=2.03 sd=0.81
#>
#> Value | Label | N | Raw % | Valid % | Cum. %
#> -------------------------------------------------
#> 1 | low | 280 | 30.84 | 31.39 | 31.39
#> 2 | moderate | 301 | 33.15 | 33.74 | 65.13
#> 3 | high | 311 | 34.25 | 34.87 | 100.00
#> <NA> | <NA> | 16 | 1.76 | <NA> | <NA>