Posts Tagged ‘ Stratified Random Sampling ’

Creating a Stratified Random Sample of a Dataframe

March 14, 2012
By
Creating a Stratified Random Sample of a Dataframe

Expanding on a question on Stack Overflow I'll show how to make a stratified random sample of a certain size: d <- expand.grid(id = 1:35000, stratum = letters)p = 0.1dsample <- data.frame()system.time(for(i in levels(d$stratum)) { dsub <...

Read more »