R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("pps-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('pps') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "calif" > > ### * calif > > flush(stderr()); flush(stdout()) > > ### Name: calif > ### Title: California places > ### Aliases: calif > ### Keywords: survey > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "califcty" > > ### * califcty > > flush(stderr()); flush(stdout()) > > ### Name: califcty > ### Title: California counties > ### Aliases: califcty > ### Keywords: survey > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "permuteinstrata" > > ### * permuteinstrata > > flush(stderr()); flush(stdout()) > > ### Name: permuteinstrata > ### Title: Randomize units within strata > ### Aliases: permuteinstrata > ### Keywords: survey > > ### ** Examples > > stratsizes <- c(9,10,10) # strata have 9, 10 and 10 units, respectively > permuteinstrata(stratsizes) [1] 3 9 5 6 2 4 8 7 1 10 11 18 14 12 13 17 15 16 19 27 28 21 24 20 29 [26] 26 25 22 23 > > > > cleanEx(); ..nameEx <- "pps1" > > ### * pps1 > > flush(stderr()); flush(stdout()) > > ### Name: pps1 > ### Title: Select one unit with PPS > ### Aliases: pps1 > ### Keywords: survey > > ### ** Examples > > sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) > sampleindex <- pps1(sizes) > > > > cleanEx(); ..nameEx <- "ppss" > > ### * ppss > > flush(stderr()); flush(stdout()) > > ### Name: ppss > ### Title: PPS systematic sampling > ### Aliases: ppss > ### Keywords: survey > > ### ** Examples > > sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) > sampleindices <- ppss(sizes,4) > > > > cleanEx(); ..nameEx <- "ppssstrat" > > ### * ppssstrat > > flush(stderr()); flush(stdout()) > > ### Name: ppssstrat > ### Title: Stratified PPS systematic sampling > ### Aliases: ppssstrat > ### Keywords: survey > > ### ** Examples > > sizes <- c(1:5,10:6)*10 > strat <- c(1,1,1,2,2,3,3,3,3,3) > n <- c(2,1,3) > ppssstrat(sizes,strat,n) [1] 1 3 4 6 8 10 > > > > cleanEx(); ..nameEx <- "ppswr" > > ### * ppswr > > flush(stderr()); flush(stdout()) > > ### Name: ppswr > ### Title: PPS sampling with replacement > ### Aliases: ppswr > ### Keywords: survey > > ### ** Examples > > sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) > sampleindices <- ppswr(sizes,4) > > > > cleanEx(); ..nameEx <- "sampford" > > ### * sampford > > flush(stderr()); flush(stdout()) > > ### Name: sampford > ### Title: Sampford's PPS sampling method > ### Aliases: sampford > ### Keywords: survey > > ### ** Examples > > size <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) > sampleindices <- sampford(size,4) > > > > cleanEx(); ..nameEx <- "sampfordpi" > > ### * sampfordpi > > flush(stderr()); flush(stdout()) > > ### Name: sampfordpi > ### Title: Joint inclusion probabilities for Sampford's PPS sampling method > ### Aliases: sampfordpi > ### Keywords: survey > > ### ** Examples > > sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) > piij <- sampfordpi(sizes,4) > weights <- 1/diag(piij) # the weights one would use for estimation > > > > cleanEx(); ..nameEx <- "sizesok" > > ### * sizesok > > flush(stderr()); flush(stdout()) > > ### Name: sizesok > ### Title: Check that unit sizes are not too big > ### Aliases: sizesok > ### Keywords: survey > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "stratsrs" > > ### * stratsrs > > flush(stderr()); flush(stdout()) > > ### Name: stratsrs > ### Title: Stratified simple random sampling > ### Aliases: stratsrs > ### Keywords: survey > > ### ** Examples > > strat <- c(1,1,1,1,1,2,2,2,3,3,3,3,3,3,3) # stratum 1 has 5 units, etc. > nh <- c(2,1,3) # select 2 units from stratum 1, 1 from stratum 2 and 3 from 3 > stratsrs(strat,nh) [1] 2 5 7 15 10 13 > > > > cleanEx(); ..nameEx <- "stratumsizes" > > ### * stratumsizes > > flush(stderr()); flush(stdout()) > > ### Name: stratumsizes > ### Title: Compute size of each stratum > ### Aliases: stratumsizes > ### Keywords: survey > > ### ** Examples > > > > > ### *