sim_covar | R Documentation |
Adds a group of variables (columns) with a given variance and covariance to a data frame or tibble
sim_covar(.data = NULL, n_obs = NULL, n_vars, var, cov, name = NA, seed = NA)
.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_vars |
Number of variables to simulate. |
var |
Variance used to construct variance-covariance matrix. |
cov |
Covariance used to construct variance-covariance matrix. |
name |
An optional name to be appended to the column names in the output. |
seed |
An optional seed for random number generation. If 'NA' (default) a random seed will be used. |
a tibble
sim_cat
, sim_discr
Other multivariate normal functions:
sim_cat()
,
sim_discr()
library(dplyr)
sim_cat(n_obs = 30, n_groups = 3) %>%
sim_covar(n_vars = 5, var = 1, cov = 0.5, name = "correlated")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.