hr_table: Generate a publication-ready table with hazard ratios

Description Usage Arguments Examples

Description

Generate a publication-ready table with hazard ratios

Usage

1
2
3
4
hr_table(data, exposure, time, status, control,
  include.unadjusted = TRUE, include.descriptive = TRUE,
  person_years_denominator = 1000, 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 data.

time

a named character vector. Names are labels for time variables. Values are column names of the time columns in data.

status

a named character vector. Names are labels for status variables. Values are column names of the status columns in 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 event rates be presented in the table?

person_years_denominator

integer. Incidence rates will be computed per this number.

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
library(survival)
library(magrittr)
library(dplyr)

data = pbc %>%
as_tibble() %>%
  mutate(
    status=case_when(
      status==2 ~ 1L,
      TRUE ~ status
    )
  ) %>%
  na.omit()

hr_table(
 data=data,
 exposure=c("Patient sex"='sex'),
 time=c("time since baseline, days"='time'),
 status=c("Death or recurrence" = 'status'),
 control=list(
   c("ascites"="ascites"),
   c("patient age"="age",
     "treatment"="trt"),
   c("bilirubin"="bili")
   )
 )

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