Learn R Programming

holodeck (version 0.2.2)

sim_cat: Simulate categorical data

Description

This is a simple wrapper that creates a tibble of length `n_obs` with a single column `groups`. It will warn if there are fewer than three replicates per group.

Usage

sim_cat(.data = NULL, n_obs = NULL, n_groups, name = "group")

Value

a tibble

Arguments

.data

An optional dataframe. If a dataframe is supplied, simulated categorical data will be added to the dataframe. Either `.data` or `n_obs` must be supplied.

n_obs

Total number of observations/rows to simulate if `.data` is not supplied.

n_groups

How many groups or treatments to simulate.

name

The column name for the grouping variable. Defaults to "group".

Details

To-do:

- Make this optionally create multiple categorical variables as being nested or crossed or random

See Also

sim_covar, sim_discr

Other multivariate normal functions: sim_covar(), sim_discr()

Examples

Run this code
df <- sim_cat(n_obs = 30, n_groups = 3)

Run the code above in your browser using DataLab