var.bin {SamplingStrata} | R Documentation |
The optimization of a frame stratification is applicable only in presence of all categorical auxiliary variables in the frame. If one or more continuous auxiliary variables are in the frame, it is necessary to pre-process in order to convert them into categorical (ordinal) variables. The applied method is the "k-means" clustering method contained in the in "stats" package. This function ensures that the final result is in an ordered categorical variable.
var.bin(x,
bins=3,
iter.max=100)
x |
Continuous variable to be transformed into a categorical one |
bins |
Number of values of the resulting categorical variable |
iter.max |
Maximum number of iterations of the clustering algorithm |
Binned variable
library(SamplingStrata)
data(swissmunicipalities)
data(swissframe)
swissframe$X1 <- var.bin(swissmunicipalities$POPTOT,bins = 18)
table(swissframe$X1)
tapply(swissmunicipalities$POPTOT,swissframe$X1,mean)