Não achei nenhum jeito oficial tbm. Fiz uma gambiarra monstra aqui criando uma coluna constante no banco de dados e chamando de Total.
Você não precisaria de teste p neh? As contagens do cabeçalho talvez dê para colocar porcentagem tbm, daí serviria como um total, mas não encontrei.
library(gtsummary)
library(tidyverse)
dados_internacao <- tibble(
Sexo = sample(c("Masc", "Fem"), size = 100, replace = TRUE),
Raca = sample(c("Branca", "Parda", "Preta"), size = 100, replace = TRUE),
Tumor = sample(c("bexiga+rim", "cabeça+tireoide"), size = 100, replace = TRUE),
Total = "Total",
Classif_SI_2 = sample(c("Ausente", "Presente"), size = 100, replace = TRUE)
)
tab1 <- dados_internacao %>%
select(Sexo,Raca, Tumor, Total, Classif_SI_2)
set.seed(42)
tab1 %>%
gtsummary::tbl_summary(by = Classif_SI_2) %>%
gtsummary::add_p(test = everything() ~ "chisq.test")
#> There was an error in 'add_p()' for variable 'Total' and test 'chisq.test', p-value omitted:
#> Error in stats::chisq.test(data[[variable]], as.factor(data[[by]])): 'x' and 'y' must have at least 2 levels
Characteristic
Ausente, N = 451
Presente, N = 551
p-value2
Sexo
0.4
Fem
24 (53%)
24 (44%)
Masc
21 (47%)
31 (56%)
Raca
0.6
Branca
17 (38%)
16 (29%)
Parda
17 (38%)
21 (38%)
Preta
11 (24%)
18 (33%)
Tumor
0.8
bexiga+rim
24 (53%)
27 (49%)
cabeça+tireoide
21 (47%)
28 (51%)
Total
Total
45 (100%)
55 (100%)
1
Statistics presented: n (%)
2
Statistical tests performed: chi-square test of independence