adorn_reg_table_format: Add formatting to a table of regression results

Description Usage Arguments Value Examples

View source: R/adorn-reg-table-format.R

Description

Add formatting to a table of regression results....

Usage

1
2
3
4
5
6
7
8
adorn_reg_table_format(
  tab,
  digits = 2,
  pval_fmt = "combo",
  format = "html",
  separate_text = " to ",
  var_labels = NULL
)

Arguments

tab

A regression table. Data frame or tibble

digits

Integer; number of digits to display (default is 2)

pval_fmt

Which p-value to show. Options are (1) "combo", default, which shows the LRT and Wald but only if there is more than one level, (2) "all" shows LRT and Wald no matter what, (3) "LRT" shows just the LRT p-value, (4) "Wald" shows just the Wald p-value.

format

Doesn't do anything right now. Place holder for later. Default is "html".

separate_text

Text to use in confidence intervals. Default is " to ".

var_labels

Variable labels

Value

A tibble or data frame

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
## Not run: 
library(epiDisplay)
library(tidyverse)

dplyr::glimpse(infert)
model0 <- glm(case ~ induced + spontaneous + education,
              family = binomial,
              data = infert)

tab1 <- display_logistic(fit = model0,
                 data = infert)

adorn_reg_table_format(tab1,
                         pval_fmt = "all")

adorn_reg_table_format(tab1,
                         pval_fmt = "combo")


adorn_reg_table_format(tab1,
                         pval_fmt = "combo")

tab2 <- display_logistic(fit = model0,
                         data = infert,
                         add_multi = TRUE)

adorn_reg_table_format(tab2,
                         pval_fmt = "combo")



# How does an interaction term work?
# This sort of works right now, but still needs work (2019-03-23)
# Does't work very well with the multivariable results
model0 <- glm(case ~ induced * education,
              family = binomial,
              data = infert)

tab3 <- display_logistic(fit = model0,
                 data = infert,
                 add_multi = FALSE)

adorn_reg_table_format(tab3,
                         pval_fmt = "all")

display_logistic(fit = model0,
                 data = infert,
                 add_multi = TRUE) %>%
  adorn_reg_table_format(.,
                         pval_fmt = "combo") %>%
  print(n = Inf)



## With labels ----------------

model0 <- glm(case ~ induced + spontaneous + education,
              family = binomial,
              data = infert)

tab4 <- display_logistic(fit = model0,
                 data = infert,
                 add_multi = TRUE)

adorn_reg_table_format(tab4,
                         pval_fmt = "combo",
                         var_labels = list(induced = "Induced (1/0)",
                                           spontaneous = "Spontaneous (1/0)",
                                           education = "Education levels"))


# Another way if the data set is already labelled

labelled::var_label(infert) <- list(induced = "Induced (1/0)",
                                    spontaneous = "Spontaneous (1/0)",
                                    education = "Education levels")

adorn_reg_table_format(tab4,
                         pval_fmt = "combo",
                         var_labels = labelled::var_label(infert))

## End(Not run)

emilelatour/latable documentation built on Jan. 10, 2020, 5:53 p.m.