# Assuming we have gender and education population totals
targets <- list(
gender = c(Male = 1000000, Female = 1050000),
education = c(HighSchool = 800000, Bachelor = 900000, Graduate = 350000)
)
data <- data.frame(
gender = c("Male", "Female", "Male", "Female", "Male"),
education = c("HighSchool", "Bachelor", "Bachelor", "HighSchool", "Graduate"),
weight = c(1, 1, 1, 1, 1)
)
raked_data <- rake_weights(data, targets, "weight")
Run the code above in your browser using DataLab