Learn R Programming

simFrame (version 0.1.2)

stratify-utilities: Utility functions for stratifying data

Description

Generic utility functions for stratifying data. These are useful if not all the information of class "Strata" is necessary.

Usage

getStrataLegend(x, design)

getStrataSplit(x, design, USE.NAMES = TRUE)

getStrataTable(x, design)

getStratumSizes(x, design, USE.NAMES = TRUE)

getStratumValues(x, design, split)

Arguments

x
the data.frame to be stratified. For getStratumSizes, it is also possible to supply a list in which each list element contains the indices of the observations belonging to the corresponding stratum (as returned by
design
a character, logical or numeric vector specifying the variables (columns) to be used for stratification.
USE.NAMES
a logical indicating whether information about the strata should be used as names for the result.
split
an optional list in which each list element contains the indices of the observations belonging to the corresponding stratum (as returned by getStrataSplit).

Value

  • For getStrataLegend, a data.frame describing the strata. For getStrataSplit, a list in which each element contains the indices of the observations belonging to the corresponding stratum. For getStrataTable, a data.frame describing the strata and containing the stratum sizes. For getStratumSizes, a numeric vector of the stratum sizes. For getStratumValues, a numeric vector giving the stratum number for each observation.

See Also

stratify, Strata

Examples

Run this code
data(eusilc)

## all data
getStrataLegend(eusilc, c("region", "gender"))
getStrataTable(eusilc, c("region", "gender"))
getStratumSizes(eusilc, c("region", "gender"))

## small sample
sam <- draw(eusilc, size = 25)
getStrataSplit(sam, "gender")
getStratumValues(sam, c("region","gender"))

Run the code above in your browser using DataLab