I have merged two tables with different rows, resulting in empty cells. I would like to replace the empty cell with an explicit "Missing" or "---" (this may also be something to implement within tbl_merge for a future feature). I tried playing around with the superstar function modify_table_styling but am having trouble finding the rows. I've tried everything() and is.na(estimate). Also, note that I actually have a tbl_merge on a tbl_merge, so my my_df$table_body is even more complex to find row identifiers in.
Thank you for your help!
library(gtsummary)
library(dplyr)
tbl_dense <-
trial %>%
tbl_summary(by = trt)
tbl_sparse <-
trial %>%
select(trt, response) %>%
tbl_summary(by = trt)
tbl_merge(list(tbl_dense, tbl_sparse)) %>%
as_kable()
| Characteristic | Drug A, N = 98 | Drug B, N = 102 | Drug A, N = 98 | Drug B, N = 102 |
|---|---|---|---|---|
| Age | 46 (37, 59) | 48 (39, 56) | ||
| Unknown | 7 | 4 | ||
| Marker Level (ng/mL) | 0.84 (0.24, 1.57) | 0.52 (0.19, 1.20) | ||
| Unknown | 6 | 4 | ||
| T Stage | ||||
| T1 | 28 (29%) | 25 (25%) | ||
| T2 | 25 (26%) | 29 (28%) | ||
| T3 | 22 (22%) | 21 (21%) | ||
| T4 | 23 (23%) | 27 (26%) | ||
| Grade | ||||
| I | 35 (36%) | 33 (32%) | ||
| II | 32 (33%) | 36 (35%) | ||
| III | 31 (32%) | 33 (32%) | ||
| Tumor Response | 28 (29%) | 33 (34%) | 28 (29%) | 33 (34%) |
| Unknown | 3 | 4 | 3 | 4 |
| Patient Died | 52 (53%) | 60 (59%) | ||
| Months to Death/Censor | 23.5 (17.4, 24.0) | 21.2 (14.6, 24.0) |
# Likely with this do-it-all function
# modify_table_styling(
# column = estimate,
# rows = is.na(estimate), # Not sure how to select rows
# missing_symbol = "MISSING"
# )
Created on 2021-07-30 by the reprex package (v2.0.0)
