stratify-utilities {simFrame}R Documentation

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 getStrataSplit).

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.

Methods for function getStrataLegend

x = "data.frame", design = "BasicVector"

get a data.frame describing the strata, according to the variables specified by design.

Methods for function getStrataSplit

x = "data.frame", design = "BasicVector"

get a list in which each element contains the indices of the observations belonging to the corresponding stratum, according to the variables specified by design.

Methods for function getStrataTable

x = "data.frame", design = "BasicVector"

get a data.frame describing the strata and containing the stratum sizes, according to the variables specified by design.

Methods for function getStratumSizes

x = "list", design = "missing"

get the stratum sizes for a list in which each list element contains the indices of the observations belonging to the corresponding stratum (as returned by getStrataSplit).

x = "data.frame", design = "BasicVector"

get the stratum sizes of a data set, according to the variables specified by design.

Methods for function getStratumValues

x = "data.frame", design = "BasicVector", split = "list"

get the stratum number for each observation, according to the variables specified by design. A previously computed list in which each list element contains the indices of the observations belonging to the corresponding stratum (as returned by getStrataSplit) speeds things up a bit.

x = "data.frame", design = "BasicVector", split = "missing"

get the stratum number for each observation, according to the variables specified by design.

Author(s)

Andreas Alfons

See Also

stratify, Strata

Examples

data(eusilcP)

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

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

[Package simFrame version 0.5.4 Index]