Skip to content
Prev 44630 / 398513 Next

Stratified random sampling in R?

Is there an easy way to do a stratified random sampling based on a factor
column in R?  E.g. I want to extract a random 10% of the data from dataset
for each class (so each class may have a different number of entries,
depending on its size).  On a related note, if this is easily doable, is
there an easy way to extract TWO non-overlapping strat. random samples
datasets (e.g. If I want to have a training and test dataset).  Thanks!

--j