ns: Sample and population strata counts

Description Usage Arguments Value

Description

Calculate counts for the stratum for each sampled unit

Usage

1
ns(sample, target_pop, formula)

Arguments

sample

a data frame including stratification variables

target_pop

a data frame with stratification variables and a variable named 'population' that contains population counts for each row. The data frame can include other stratification variables than those in fmla and counts will be aggregated over these variables

fmla

a one-sided formula of the form ~a + b + c ... where 'a', 'b', 'c', ... are stratification variables in both sample and in target_pop

Value

the sample data frame with two additional variables 'n', 'N' giving the stratum counts in the sample and in the population, respectively. If some strata combinations are missing in the sample, a row for each missing combination is added with n equal to 0 and N equal to the count for that stratum in the population


gmonette/WWCa documentation built on May 17, 2019, 7:25 a.m.