if (FALSE) {
set.seed(123)
df <- expand.grid(
school = paste0("S", 1:5),
class = paste0("C", 1:5),
student = paste0("P", 1:5)
)
df$score <- rnorm(nrow(df))
resampled <- clusterResample(df, clusters = c("school", "class", "student"),
replace = c(TRUE, TRUE, FALSE))
}
Run the code above in your browser using DataLab