Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id <- 1:80000
- N = 80000
- group <- rep(1:8, each = 10000)
- group_selection_probability <- c(0.4,0.3,0.15,0.05,0.04,0.03,0.02,0.01)
- group_selection_probability <- rep(group_selection_probability, each = 10000)
- weight <- (group_selection_probability/sum(group_selection_probability))*N
- data <- data.frame(id,group,weight)
- sample <- dplyr::sample_n(data, size = 1000, weight = weight)
- table(sample$group)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement