svy_tbl: Create a table from a survey data frame

Description Usage Arguments Value Examples

Description

Quick and simple methods for creating a weighted frequency table for columns in a svy_df object. Printing the table will return formatted output with the question text of x.

Usage

1
2
3
## S3 method for class 'svy_df'
table(data, x, y = NULL, w = NULL, prop = FALSE,
  digits = 0)

Arguments

data

A survey data frame created by svy_df.

x,y

character: Column names in data to tabualte. If y is not NULL, creates a two-way frequency table.

w

character: Optional column name containing a vector of survey weights.

prop

logical: If TRUE, print proportions instead of counts.

digits

numeric: Number of digits to round counts to.

Value

A (weighted) frequency table of class svy_tbl.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Make sure `data` is a svy_df
is.svy_df(data)

## Make a one-way frequency table
my.tab1 <- table(data, "nr2", w = "wts")

## Make a table of two variables
my.tab2 <- table(data, "nr2", "demGender", "wts")

## Print formatted output
my.tab2

alexdulin/MCmrp documentation built on May 11, 2019, 11:29 p.m.