Recode a latent variable into a Likert response variable
Source:R/variable_creation_functions.R
draw_likert.Rd
Recode a latent variable into a Likert response variable
Arguments
- x
a numeric variable considered to be "latent"
- min
the minimum value of the latent variable
- max
the maximum value of the latent variable
- bins
the number of Likert scale values. The latent variable will be cut into equally sized bins as in seq(min, max, length.out = bins + 1)
- breaks
A vector of breaks. This option is useful for settings in which equally-sized breaks are inappropriate
- labels
An optional vector of labels. If labels are provided, the resulting output will be a factor.
Examples
x <- 1:100
draw_likert(x, min = 0, max = 100, bins = 7)
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3
#> [38] 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6
#> [75] 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
draw_likert(x, breaks = c(-1, 10, 100))
#> [1] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
#> [38] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
#> [75] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2