Description Usage Arguments Value Examples
Group data by combinations of stratum values and count the records falling into each combination.
1 2 |
x |
Data frame with stratum values in columns |
strataVars |
List of strata variables. By default it is created from all
but the first columns of |
column.n |
Column name to be used in the output for the column containing the number of records falling into the combination of stratum values. |
column.stratum |
Column name to be used in the output for the column containing the stratum identifier |
format.stratum |
format string to be used in |
Data frame with each row representing a combination of stratum values
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Define stratifying variables
strataVars <- list(sex = c("female", "male"), medication = c("yes", "no"))
# Create some random testdata
x <- createTestdata(strataVars)
# Count records in each stratum
stratify(x, strataVars)
stratify(x, strataVars, column.n = "n.patients")
# Create testdata with defined numbers of records in each stratum
n.per.stratum <- 1:4
y <- createTestdata(strataVars, n.per.stratum = n.per.stratum)
# Count records in each stratum
(counts <- stratify(y, strataVars))
# Check if the numbers of records in each stratum are as expected
all(counts$n == n.per.stratum)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.