Hi PJ,
I went back to the original data for the tables and used rbind() to get a full table.
datapasta::dpasta(modelstibble::tribble(
~Covariates, ~Mono, ~Neu, ~NK, ~CD4T, ~CD8T, ~Bcell,
"Age, sex, smoking, technical", 0.628417355082566, 0.000519604887456513, 0.0925500673787777, 0.00584722383176443, 0.00110636778126264, 0.00448981271134747,
"Age, sex, smoking, technical, blood-draw time", 0.776347680248465, 0.00333944782506215, 0.286264314573566, 0.0186336833741003, 0.00974265172264351, 0.0260571208261442,
"Age, sex, smoking, technical", 0.126203612800461, 0.0069822247870482, 0.898970562719821, 0.00124800394720716, 0.237536193109084, 0.24719207837134,
"Age, sex, smoking, technical, blood-draw time", 0.0602578745322921, 0.0110018346892553, 0.772246388504049, 0.00191661864623293, 0.339897214377786, 0.310222407363504
)
)
Nice code for the p-value stars courtesy of statistishdan 
# function to round p-value and append stars
add_stars <- function(x, decimals = 3) {
# create vector of stars
x_stars <-
dplyr::case_when(
x >= 0.05 ~ "",
x >= 0.01 ~ "*",
x >= 0.001 ~ "**",
TRUE ~ "***"
)
# paste together rounded p-value and stars
paste0(
gtsummary::style_number(x, digits = decimals),
x_stars
)
}
# gt function to round p-values and add stars
fmt_stars <- function(data,
columns,
rows = NULL,
decimals = 3) {
fmt(
data = data,
columns = {{ columns }},
rows = {{ rows }},
fns = purrr::partial(add_stars, decimals = decimals)
)
}
table <- gt(models) %>%
fmt_stars(columns = 2:7, decimals = 3) %>%
cols_align(
align = "left")
table
Adding the row labels courtesy of you.
library(gt)
gtTable = gt(table) %>%
tab_row_group(
group = "All cases (N = 333) versus controls (N = 396)",
rows = 1:2
) %>%
tab_row_group(
group = "Medication-free cases (N = 51) versus controls (N = 315)",
rows = 3:4
)
gtTable
But I get this error code:
Error in UseMethod("group_vars") : no applicable method for 'group_vars' applied to an object of class "c('gt_tbl', 'list')"
Thanks again for your help.
Jonelle