drawing a stratified sample in R
问题 Designing my stratified sample library(survey) design <- svydesign(id=~1,strata=~Category, data=billa, fpc=~fpc) So far so good, but how can I draw now a sample in the same way I was able for simple sampling? set.seed(67359) samplerows <- sort(sample(x=1:N, size=n.pre$n)) 回答1: If you have a stratified design, then I believe you can sample randomly within each stratum. Here is a short algorithm to do proportional sampling in each stratum, using ddply : library(plyr) set.seed(1) dat <- data