Random Likert distribution
Usage
rlikert(n, prob, labels = names(prob))
Examples
# no names or labels returns integer vector of values 1:length(prob)
prob <- c(.1, .2, .4, .2, .1)
rlikert(10, prob)
#> [1] 5 3 3 5 5 5 5 2 3 3
# named prob returns factor
prob <- c(A = 10, B = 20, C = 30)
rlikert(10, prob)
#> [1] C B A A C C B B C B
#> Levels: A B C
# specify labels if prob not named and not 1:length(prob)
labels <- -2:2
prob <- rep(1, length(labels)) # uniform probability
rlikert(10, prob, labels)
#> [1] -2 2 1 -2 0 2 1 2 0 2