make_summary: Summarize data from a stratified random sample

Description Usage Arguments Value Examples

View source: R/make_summary.R

Description

Support for computing tables of statistics for stratified variables. Wraps mk_stat for each subgroup (stratum). Only supports stratification by one variable at this time.

Usage

1
2
3
4
5
6
7
8
9
make_summary(
  .data,
  .group,
  .y,
  .group_N,
  .stat = "mean",
  .group_weights = NULL,
  .fpc = TRUE
)

Arguments

.data

A dataframe or tibble of data

.group

A stratifying variable as a column in the data

.y

An observation variable in the data

.group_N

An exogeneous vector of population sizes for each subgroup to join to the data when computing stratified effects.

.stat

One of "mean", "total" or "prop"

.group_weights

Optional column of weights in the dataframe. If weights are given in the dataframe, they will be used in place of the population vector (.group_N), although .group_N is still a required argument.

.fpc

Logical variable: indicates whether to compute a finite popoulation correction.

Value

A tibble (data.frame-like structure)

Examples

1
2
3
d <- data.frame("stratum"=rep(1:5, 6), "y"=rnorm(30, 30, 3))
N <- 50
make_summary(d, stratum, y, N)

danjdrennan/surveyr documentation built on Dec. 19, 2021, 8:08 p.m.