Deleting specific gtsummary table cell value

113 Views Asked by At

I would like to delete the content of the cell corresponding to "Company B", group "F" and Score_level "low" (it has the value 2 (29%)) for the table generated by the code below.

Searching the gtsummary documentation, there are examples on how to delete a cell value based on its column. In the case of this table, the column name would be stat_1_2.

However, the problem is that this column has two identical values, and i want to keep one of them (cell value for "Company B", group "F" and Score_level "Average") and only delete the one mentioned above.

If gt table conversion would help I would gladly use it but have not found a way yet. Any help would be much appreciated.

library(tidyverse)
library(reprex)
library(gtsummary)


Score_level <- c("Low", "High", "Average", "Low", "High", "Average","Low", "High", "Average","Low", "High", "Average","Low", "High", "Average", "Low")
Gender <- c("M", "F", "M", "F","M", "F","M", "F","M", "F","M", "F","M", "F", "M", "F")
Company <- c("Company_A", "Company_B", "Company_B", "Company_A","Company_A", "Company_B","Company_A", "Company_B","Company_A", "Company_B","Company_A", "Company_B","Company_A", "Company_B", "Company_A", "Company_B")

df <- data.frame(Score_level, Gender, Company)


df %>%
  tbl_strata(strata = Company, 
             .tbl_fun = ~ .x %>%
               tbl_summary(by = Gender,
                           statistic = all_categorical() ~ "{n} ({p}%)",
                           missing_text = "(Missing Data)") %>%
               modify_header(label = "**Outcome**")) 

Created on 2023-10-26 with reprex v2.0.2

0

There are 0 best solutions below