Description Usage Arguments Value See Also Examples
View source: R/r_sample_ordered.R
Generate a random vector and coerces to an ordered factor.
1 | r_sample_ordered(n, x = LETTERS[1:5], prob = NULL, name = "Ordered")
|
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 |
Returns a random factor vector of elements.
1 2 3 4 5 6 7 8 9 | 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)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.