intermediate_surv_prop_table: An intermediate helper function for surv_prop_table

Description Usage Arguments Value Examples

View source: R/prop_tables.R

Description

An intermediate helper function for surv_prop_table

Usage

1
2
intermediate_surv_prop_table(s, outcome_vars, grouping_vars,
  new_outcome_name = "outcome", binary = F)

Arguments

s

A tbl_svy object created using the srvyr package.

outcome_vars

A character vector naming the column(s) in s to be used as outcomes variable(s). These must be binary or categorial columns in s (convert beforehand if needed).

grouping_vars

A character vector naming the column(s) in s to be used as grouping variable(s). These must be binary or categorial columns in s (convert beforehand if needed).

new_outcome_name

Character with intended name of the column to hold the names of the outcome variables. Ignored if only 1 outcome.

binary

Logical indicating whether the outcome(s) are binary in which case only one column of outcome values will be displayed.

Value

A long format tibble. Each of the initial character columns is named for a grouping variable and list combination of grouping categories for that row The later numeric columns are named for the outcome categories and list the percentages falling into each. Rows should sum to 100, unless outcome is binary in which case only the column for "TRUE" is displayed to avoid redudancy.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(ca_school_tbl_svy)
# Multiple grouping variables
ca_school_tbl_svy %>%
  intermediate_surv_prop_table(outcome_vars = "school.level",
                 grouping_vars = c("sch.wide.imp.goal", "comparative.imp.goal"))

# Multiple outcomes
ca_school_tbl_svy %>%
 intermediate_surv_prop_table(outcome_vars = c("sch.wide.imp.goal", "comparative.imp.goal"),
                grouping_vars = "school.level",
                new_outcome_name = "met_standards")

# Binary outcome
ca_school_tbl_svy %>%
 intermediate_surv_prop_table(outcome_vars = "eligible.for.award",
                grouping_vars = "school.level",
                binary = T)

mattysimonson/exploratorium documentation built on Dec. 21, 2021, 3:49 p.m.