# NOT RUN {
# the schools00 dataset has a large sample size, so expected segregation is close to zero
mutual_expected(schools00, "race", "school", weight = "n")
# but we can build a smaller table, with 100 students distributed across
# 10 schools, where one racial group has 10% of the students
small <- data.frame(
school = c(1:10, 1:10),
race = c(rep("r1", 10), rep("r2", 10)),
n = c(rep(1, 10), rep(9, 10)))
mutual_expected(small, "race", "school", weight= "n")
# with an increase in sample size (n=1000), the values improve
small$n <- small$n * 10
mutual_expected(small, "race", "school", weight= "n")
# }
Run the code above in your browser using DataLab