pr_table: Generate a nice table with prevalence ratios

Description Usage Arguments Examples

Description

Generate a nice table with prevalence ratios

Usage

1
2
3
pr_table(data, exposure, outcome, control, include.unadjusted = TRUE,
  include.descriptive = TRUE, return_data = FALSE,
  collapse_footer = FALSE)

Arguments

data

a data frame

exposure

a named character vector. Names are variable labels. Values are column names in the data.

outcome

a named character vector. Names are outcome labels. Values are column names of the outcomes in the data.

control

a list of character vectors. The ith item in the list should contain column names of variables that will be added as control variables for the ith model. Naming the character vectors will result in the names being used as labels for control variables in the footnote of the table.

include.unadjusted

logical. Should unadjusted prevalence ratios be presented in the table?

include.descriptive

logical. Should the prevalence of the outcome be presented in the table?

return_data

logical. Should the table data be returned instead of the table?

collapse_footer

logical. Should the model footnote be collapsed?

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
library(titanic)
library(magrittr)
library(dplyr)
library(gt)

data <- titanic_train %>%
  dplyr::select(Survived, Pclass, Sex, Age, SibSp, Fare) %>%
  as_tibble() %>%
  dplyr::mutate(
    Pclass=factor(
      Pclass,
      levels=c(1,2,3),
      labels=c("1st Class","2nd Class","3rd Class")
    )
  ) %>%
  na.omit()

tst_output <- pr_table(
  data=data,
  exposure=c("Passenger class"='Pclass'),
  outcome=c("Survival"='Survived'),
  control=list(
    c("Passenger gender"="Sex"),
    c("Passenger age"="Age",
      "Ticket price"="Fare"),
    c("Gender by age interaction"="Sex:Age")
  ),
  include.unadjusted=TRUE,
  include.descriptive=TRUE
)

bcjaeger/Solo documentation built on May 14, 2019, 11:03 p.m.