add_var_random_cat | R Documentation |
Add a random categorical variable to dataset
add_var_random_cat(
data,
name = "random_cat",
cat = LETTERS[1:6],
prob,
overwrite = TRUE,
seed
)
data |
A dataset |
name |
Name of new variable (as string) |
cat |
Vector of categories |
prob |
Vector of probabilities |
overwrite |
Can new random variable overwrite an existing variable in dataset? |
seed |
Seed for random number generation (integer) |
Dataset containing new random variable
library(magrittr)
iris %>% add_var_random_cat() %>% head()
iris %>% add_var_random_cat(name = "my_cat") %>% head()
iris %>% add_var_random_cat(cat = c("Version A", "Version B")) %>% head()
iris %>% add_var_random_cat(cat = c(1,2,3,4,5)) %>% head()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.