data(api)
## pretend the sampling was stratified on three variables
poptable<-xtabs(~sch.wide+comp.imp+stype,data=apipop)
sample.count<-xtabs(~sch.wide+comp.imp+stype,data=apiclus1)
sample.weight<-xtabs(pw~sch.wide+comp.imp+stype, data=apiclus1)
## create a nonresponse object
nr<-nonresponse(sample.weight,sample.count, poptable)
## sparse cells
sparseCells(nr)
## Look at neighbours
neighbours(3,nr)
neighbours(11,nr)
## Collapse some contiguous cells
nr1<-joinCells(nr,3,5,7)
## sparse cells now
sparseCells(nr1)
nr2<-joinCells(nr1,3,11,8)
nr2
## one relatively sparse cell
sparseCells(nr2)
## but nothing suitable to join it to
neighbours(3,nr2)
## extract the weights
weights(nr2)
Run the code above in your browser using DataLab