Learn R Programming

SamplingStrata (version 1.5-4)

updateStrata: Assigns new labels to atomic strata on the basis of the optimized aggregated strata

Description

Once optimal stratification has been obtained ('outstrata'), then we need to attribute new strata labels to each atomic stratum. By executing this function, a new dataframe "newstrata" will be obtained with the same structure of the old, ("strata") but with the addition of a new stratum label. By indicating "YES" to "writeFile" parameter, the dataframe "newstrata" will be written to a delimited file ("newstrata.txt"). Also a second delimited file ("strata_aggregation.txt") will be outputted, containing the indication of the relations bewteen atomic and aggregated strata.

Usage

updateStrata(strata, solution, writeFiles = FALSE)

Value

A dataframe containing the strata

Arguments

strata

This is the (mandatory) dataframe containing the information related to the atomic strata to which the optimisation has been applied to.

solution

List obtained by the execution of the "optimizeStrata" function. The first element of the list is the vector of the indices corresponding to the optimal solution.

writeFiles

Indicates if at the end of the processing the resulting strata will be outputted in a delimited file. Default is "FALSE".

Author

Giulio Barcaroli

Examples

Run this code
if (FALSE) {
library(SamplingStrata)
data(swisserrors)
data(swissstrata)
# optimisation of sampling strata
solution <- optimizeStrata ( 
    errors = swisserrors, 
    strata = swissstrata, 
)
# updating sampling strata with new strata labels
newstrata <- updateStrata(swissstrata, solution, writeFiles = TRUE)
}

Run the code above in your browser using DataLab