
Turns a dic variable into a factor based on the value labels
factor_by_label.RdTurns a dic variable into a factor based on the value labels
Examples
dat_dic <- apply_dic(ex_scaledic_data, ex_scaledic_dic)
#> Found the following invalid values:
#>
#> 'rel_2' is 66 at row 3
#> 'rel_4' is 11 at row 9
#> 'rel_5' is 66 at row 11
#> 'sui_1' is 55 at row 10
#> 'sui_4' is 66 at row 17
#> 'age' is 13, 13 at rows 4, 16
#>
#> Cautions:
#> 1: Invalid values replaced with NA
#> 2: Missing values replaced with NA
#> 3: Scales scored
# Proportions of responses
dat_dic$rel_2 |> factor_by_label() |> table() |> prop.table()
#>
#> Rarely or never A few times a month Once a week
#> 0.2631579 0.1578947 0.1052632
#> Two or more times/week Daily More than once a day
#> 0.1052632 0.2105263 0.1578947
# A cross table
table(factor_by_label(dat_dic$rel_1), dat_dic$gender)
#>
#> m f d
#> Never 0 1 1
#> Once a year or less 1 2 1
#> A few times a year 1 1 3
#> A few times a month 0 1 0
#> Once a week 1 1 0
#> More than once/week 4 1 0