Learn R Programming

SamplingStrata (version 1.5-4)

plotStrata2d: Plot bivariate distibutions in strata

Description

Plots a 2d graph showing obtained strata

Usage

plotStrata2d (x,outstrata,domain,vars,labels)

Value

A formatted output containing information on the strata in the given domain

Arguments

x

the sampling frame

outstrata

the optimized strata

domain

a domain in the frame

vars

vars to appear in x and y axis

labels

labels to appear in x and y axis

Examples

Run this code
if (FALSE) {
library(SamplingStrata)
data("swissmunicipalities")
swissmunicipalities = swissmunicipalities[swissmunicipalities$REG==1,]
data("errors")
swissmunicipalities$id <- c(1:nrow(swissmunicipalities))
swissmunicipalities$domain = 1
frame <- buildFrameDF(swissmunicipalities,
                      id = "id",
                      domainvalue = "REG",
                      X = c("Surfacesbois","Surfacescult"),
                      Y = c("Pop020", "Pop2040")
)
solution <- optimStrata (method = "continuous",
                        errors = errors,, 
                        framesamp = frame,
                        nStrata = 8, 
                        iter = 25, 
                        pops = 10) 
p <- plotStrata2d(solution$framenew, 
                  solution$aggr_strata,
                  domain = 1, 
                  vars = c("X1","X2"),
                  labels = c("Surfacesbois","Surfacescult"))
p
}

Run the code above in your browser using DataLab