ssamp: Draws stratifed sample without replacement using proportional...

Description Usage Arguments Value Examples

View source: R/ssamp.R

Description

Draws stratifed sample without replacement using proportional allocation

Usage

1
ssamp(df, n, strata, over = 1)

Arguments

df

object containing full sampling data frame (e.g. data)

n

sample size (integer) or object containing sample size

strata

variable in sampling data frame by which to stratify (e.g. region)

over

(optional) desired oversampling proportion (defaults to 0; takes value between 0 and 1 as input)

Value

Returns stratified sample without replacement

Examples

1
2
3
4
ssamp(df=albania, n=360, strata=qarku, over=0.1)

size <- rsampcalc(nrow(albania), 3, 95, 0.5)
stratifiedsample <- ssamp(albania, size, qarku)

Example output

# A tibble: 395 x 45
   qarku  Q_ID bashkia BAS_ID zaz   njesiaAdministrCOM_ID qvKod zgjedhes
   <fct> <int> <fct>    <int> <fct> <fct>             <int> <fct>    <int>
 1 Berat     1 Kucove      13 ZAZ"Perondi"          1203 "\"3…      835
 2 Berat     1 Berat       11 ZAZ … "Berat "           1101 "\"3…      580
 3 Berat     1 Skrapar     17 ZAZ … "Potom"            1307 "\"3…      247
 4 Berat     1 Kucove      13 ZAZ … "Lumas"            1104 "\"3…      919
 5 Berat     1 Ura Va…     19 ZAZ … "Cukalat"          1102 "\"3…      584
 6 Berat     1 Polican     15 ZAZ … "Terpan"           1109 "\"3…      407
 7 Berat     1 Ura Va…     19 ZAZ … "Kutalli"          1103 "\"3…      912
 8 Berat     1 Berat       11 ZAZ … "Berat "           1101 "\"3…      604
 9 Berat     1 Berat       11 ZAZ … "Berat "           1101 "\"3…      494
10 Berat     1 Skrapar     17 ZAZ … "Corovode"         1303 "\"3…      735
# … with 385 more rows, and 36 more variables: meshkuj <int>, femra <int>,
#   totalSeats <int>, vendndodhja <fct>, ambienti <fct>, totalVoters <int>,
#   femVoters <int>, maleVoters <int>, unusedBallots <int>,
#   damagedBallots <int>, ballotsCast <int>, invalidVotes <int>,
#   validVotes <int>, lsi <int>, ps <int>, pkd <int>, sfida <int>, pr <int>,
#   pd <int>, pbdksh <int>, adk <int>, psd <int>, ad <int>, frd <int>,
#   pds <int>, pdiu <int>, aak <int>, mega <int>, pksh <int>, apd <int>,
#   libra <int>, psSeats <int>, pdSeats <int>, lsiSeats <int>, pdiuSeats <int>,
#   psdSeats <int>

sampler documentation built on Sept. 15, 2019, 5:02 p.m.