cosm_reg: Cosmetics for tables of regression coefficients. Converts...

Description Usage Arguments Value Examples

View source: R/misc_functions.R

Description

Cosmetics for tables of regression coefficients. Converts tables generated by tbl_regression to huxtable and adds some cosmetics.

Usage

1
cosm_reg(gt_tbl, pad = 3, type = 3, bold = TRUE, head_label = "**Variable**")

Arguments

gt_tbl

A table object generated by tbl_regression.

pad

Numerical, padding above and bellow rows.

type

Anova's type to calculate global p-values.

bold

Display labels in bold?

head_label

Character, label to be used as head for the variable's column.

Value

A huxtable.

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
require(sjlabelled, quietly = TRUE)

data(diet, package = "Epi")
diet <- diet %>%
  var_labels(
    chd = "Coronary Heart Disease",
    fibre = "Fibre intake (g/day)"
  )

model_binom <- glm(chd ~ fibre, data = diet, family = binomial)

model_binom %>%
  tbl_regression(exponentiate = TRUE) %>%
  cosm_reg(bold = TRUE) %>%
  theme_pubh(1) %>%
  add_footnote(get_r2(model_binom), font_size = 9)

data(birthwt, package = "MASS")
birthwt <- birthwt %>%
  mutate(
    smoke = factor(smoke, labels = c("Non-smoker", "Smoker")),
    race = factor(race, labels = c("White", "African American", "Other"))
  ) %>%
  var_labels(
    bwt = "Birth weight (g)",
    smoke = "Smoking status",
    race = "Race"
  )

model_norm <- lm(bwt ~ smoke + race, data = birthwt)

model_norm %>%
  tbl_regression() %>%
  cosm_reg(bold = TRUE) %>%
  theme_pubh(1) %>%
  add_footnote(get_r2(model_norm), font_size = 9)

pubh documentation built on Oct. 11, 2021, 9:10 a.m.