# NOT RUN {
The following example will select a sample from an area resource. The design
includes two strata. For Stratum 1, an equal probability sample of size 50
will be selected for a single panel. For Stratum 2, an unequal probability
sample of size 50 will be selected for each of two panels. The sample for
Stratum 2 will be approportioned into samples of size 25 for each of four
unequal probability categories. In addition both strata will include
oversamples (size 10 for Stratum 1 and size 75 for Stratum 2). It is assumed
that a shapefile defining the polygons for the area resource is located in the
folder from which R is started. Attribute data for the design will be read
from the dbf file of the shapefile, which is assumed to have variables named
"test.stratum" and "test.mdcaty" that specify stratum membership value and
unequal probability category, respectively, for each record in the shapefile.
A shapefile named "test.sample" containing the survey design information will
be created.
test.design <- list("Stratum 1"=list(panel=c(Panel=50), seltype="Equal",
over=10), "Stratum 2"=list(panel=c("Panel One"=50, "Panel Two"=50),
seltype="Unequal", caty.n=c(CatyOne=25, CatyTwo=25, CatyThree=25,
CatyFour=25), over=75))
test.attframe <- read.dbf("test.shapefile")
test.sample <- grts(design=test.design, DesignID="Test.Site", type.frame="area",
src.frame="shapefile", in.shape="test.shapefile", att.frame=test.attframe,
stratum="test.stratum", mdcaty="test.mdcaty", shapefile=TRUE,
out.shape="test.sample")
# }
Run the code above in your browser using DataLab