Description Usage Arguments Examples
The ability to randomly sub-sample population data "in silico" is essential for investigations such as sample effects on parameter estimation. This function sample row values of a data frame conditional to some strata attributes.
| 1 2 | 
| .data | the data frame. | 
| group | the grouping factor, may be a list. | 
| size | the sample size. | 
| select | if sampling from a specific group or list of groups. | 
| replace | should sampling be with replacement? | 
| both.sets | if  | 
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | data(pollster2008)
# Let's take a 10% sample from all -PollTaker- groups in pollster2008
 stratify(pollster2008, "PollTaker", 0.1)
 # Let's take a 10% sample from only 'LV' and 'RV' groups from -Pop- in pollster2008
 stratify(pollster2008, "Pop", 0.1, select = list(Pop = c("LV", "RV")))
 # Let's take 3 samples from all -PollTaker- groups in pollster2008,
 # specified by column 1
stratify(pollster2008, group = 1, size = 3)
# Let's take a sample from all -Pop- groups in pollster2008, where we
# specify the number wanted from each group
stratify(pollster2008, "Pop", size = c(3, 5, 4))
# Use a two-column strata (-Pop- and -PollTaker-) but only interested in
# cases where -Pop- == 'LV'
stratify(pollster2008, c("Pop", "PollTaker"), 0.15, select = list(Pop = "LV"))
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.