r_sample_ordered {wakefield} | R Documentation |
Generate Random Ordered Factor Vector
Description
Generate a random vector and coerces to an ordered factor.
Usage
r_sample_ordered(n, x = LETTERS[1:5], prob = NULL, name = "Ordered")
Arguments
n |
The number elements to generate. This can be globally set within
the environment of |
x |
A vector of elements to chose from. |
prob |
A vector of probabilities to chose from. |
name |
The name to assign to the output vector's |
Value
Returns a random factor vector of elements.
See Also
Examples
r_sample_ordered(100, name = "Var")
lvls <- c("Strongly Agree", "Agree", "Neutral", "Disagree", "Strongly Disagree")
table(r_sample_ordered(x = lvls, n=1000))
(out <- r_sample_ordered(x = c("Black", "Grey", "White"),
prob = c(.5, .2, .3), n = 100))
slices <- c(table(out))
pie(slices, main="Pie Chart of Colors", col = tolower(names(slices)))
[Package wakefield version 0.3.6 Index]