Description Usage Arguments Examples
Generate a publication-ready table with hazard ratios
1 2 3 4 |
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? |
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")
)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.