library(tidyverse)
library(reprex)
# 0 women
# 1 men
actual <- c(0, 2, 3, 0, 4, 3, 2, 2)
students <- rep(0, 4*length(actual) - sum(actual)) %>%
append(rep(1, sum(actual)))
results <- c()
trial <- c()
for (i in 1:500) {
for (f in length(actual)) {
temp <- sample(students, 4, replace = FALSE)
trial[f] <- sum(temp, na.rm = TRUE)
}
results[i] <- var(trial)
trial <- c()
}
Created on 2020-02-12 by the reprex package (v0.3.0)