Analisis exploratorio de la base de datos

library(readxl)

BASE <- read_excel("Base de datos bariatrica revisada 14 agosto.xlsx", 
    sheet = "CIRUGIA BARIATRICA") #HOJA PRINCIPAL

BASE_BED_Q <- read_excel("Base de datos bariatrica revisada 14 agosto.xlsx", 
    sheet = "BED Q") #ESCALA BED Q

BASE_GERDQ <- read_excel("Base de datos bariatrica revisada 14 agosto.xlsx", 
    sheet = "GERDQ") # ESCALA GERD Q

#En la base general se reemplaza el valor de los datos faltantes
BASE$`Tipo de cirugía bariátrica`[is.na(BASE$`Tipo de cirugía bariátrica`)] <- "Control"


#Se filtran los pacientes que tuvieron MAMOMETRIA 

library(dplyr)

BASE <- BASE %>% filter(Manometria == "Si") #102 pacientes

#Se codifica la ortografia 
BASE$`Síntoma principal` <- tolower(BASE$`Síntoma principal`)

BASE$`Sintomas secundario` <- tolower(BASE$`Sintomas secundario`)

BASE$Clasificación <- "Chicago 4.0"

BASE$`Especificar cual otro diagnostico endoscópico` <- tolower(BASE$`Especificar cual otro diagnostico endoscópico`)


BASE$`Especificar cual otro diagnostico endoscópico` <- ifelse(BASE$`Especificar cual otro diagnostico endoscópico` %in% c("esofagitis grado b", "grado a esofagitis", "grado b esofagitis", "esofagitis"), "Esofagitis", BASE$`Especificar cual otro diagnostico endoscópico`)




#Se ejecuta el analisis exploratorio de la base (sin número de cédula)

library(summarytools)
print(dfSummary(BASE[,-1]), method = 'render')

Data Frame Summary

BASE

Dimensions: 102 x 23
Duplicates: 0
No Variable Stats / Values Freqs (% of Valid) Graph Valid Missing
1 Manometria [character] 1. Si
102(100.0%)
102 (100.0%) 0 (0.0%)
2 Clasificación [character] 1. Chicago 4.0
102(100.0%)
102 (100.0%) 0 (0.0%)
3 Edad [numeric]
Mean (sd) : 54.7 (12)
min ≤ med ≤ max:
29 ≤ 55 ≤ 78
IQR (CV) : 17 (0.2)
40 distinct values 102 (100.0%) 0 (0.0%)
4 Genero [character]
1. femenino
2. masculino
84(82.4%)
18(17.6%)
102 (100.0%) 0 (0.0%)
5 Síntoma principal [character]
1. disfagia
2. dolor toracico
3. emesis
4. pirosis
5. regurgitacion
8(15.4%)
3(5.8%)
1(1.9%)
27(51.9%)
13(25.0%)
52 (51.0%) 50 (49.0%)
6 Sintomas secundario [character]
1. disfagia
2. dolor toracico
3. globus
4. regurgitacion
13(54.2%)
6(25.0%)
1(4.2%)
4(16.7%)
24 (23.5%) 78 (76.5%)
7 IMC (Índice de masa corporal) [numeric]
Mean (sd) : 24.3 (4.2)
min ≤ med ≤ max:
19 ≤ 23 ≤ 40
IQR (CV) : 6 (0.2)
17 distinct values 102 (100.0%) 0 (0.0%)
8 Tipo de cirugía bariátrica [character]
1. 1 bypass/ Y Roux
2. Control
3. Manga gástrica
18(17.6%)
50(49.0%)
34(33.3%)
102 (100.0%) 0 (0.0%)
9 Diagnostico en endoscopia [character]
1. Hernia hiatal
2. otro
37(36.6%)
64(63.4%)
101 (99.0%) 1 (1.0%)
10 Especificar cual otro diagnostico endoscópico [character]
1. Esofagitis
2. gastritis
3. gastropatia
4. grado a hernia hiatal
5. hernia paraesofagica
6. normal
7. polipo
8. varices esofagicas pequeñ
6(8.1%)
57(77.0%)
4(5.4%)
1(1.4%)
1(1.4%)
2(2.7%)
2(2.7%)
1(1.4%)
74 (72.5%) 28 (27.5%)
11 Tiempo en años desde la cirugía bariátrica hasta el inicio de síntomas [numeric]
Mean (sd) : 6.8 (3.7)
min ≤ med ≤ max:
1 ≤ 6 ≤ 20
IQR (CV) : 3 (0.5)
11 distinct values 24 (23.5%) 78 (76.5%)
12 Manometría: DCI promedio [numeric]
Mean (sd) : 1712.9 (1795.7)
min ≤ med ≤ max:
0 ≤ 1301.5 ≤ 15190
IQR (CV) : 1284.2 (1)
99 distinct values 102 (100.0%) 0 (0.0%)
13 Manometría: IRP [character]
1. 2.5
2. 13.4
3. 5.8
4. 6.9
5. 7.6
6. 12.5
7. 13.8
8. 13.9
9. 14.8
10. 2.1
[ 64 others ]
4(3.9%)
3(2.9%)
3(2.9%)
3(2.9%)
3(2.9%)
2(2.0%)
2(2.0%)
2(2.0%)
2(2.0%)
2(2.0%)
76(74.5%)
102 (100.0%) 0 (0.0%)
14 Manometría: Presión intragástrica [character]
1. mayor a 30 mm Hg
2. menor a 30 mm Hg
58(56.9%)
44(43.1%)
102 (100.0%) 0 (0.0%)
15 Manometría: Presión basal del LES [character]
1. 12.1
2. 13
3. 13.5
4. 15.6
5. 18.100000000000001
6. 18.5
7. 19.600000000000001
8. 20.399999999999999
9. 20.6
10. 20.9
[ 76 others ]
2(2.0%)
2(2.0%)
2(2.0%)
2(2.0%)
2(2.0%)
2(2.0%)
2(2.0%)
2(2.0%)
2(2.0%)
2(2.0%)
82(80.4%)
102 (100.0%) 0 (0.0%)
16 Presión intrabolo [character]
1. mayor a 20 mm Hg
2. menor a 20 mm Hg
27(26.5%)
75(73.5%)
102 (100.0%) 0 (0.0%)
17 Aclaramiento del bolo [character]
1. Completo
2. Incompleto
81(83.5%)
16(16.5%)
97 (95.1%) 5 (4.9%)
18 Manometría: Presurización pan esofágica en isocontorno de 20 mm Hg [character]
1. No
2. Si
99(97.1%)
3(2.9%)
102 (100.0%) 0 (0.0%)
19 Manometría: IRP en la prueba de RDC [numeric]
Mean (sd) : 2.5 (5.5)
min ≤ med ≤ max:
0.1 ≤ 0.8 ≤ 47.8
IQR (CV) : 2.6 (2.2)
30 distinct values 99 (97.1%) 3 (2.9%)
20 Manometría: Test de reserva peristáltica [character]
1. Adecuado
2. Inadecuado
79(77.5%)
23(22.5%)
102 (100.0%) 0 (0.0%)
21 Manometría: Ausencia de inhibición deglutoria [character]
1. No
2. Si
92(90.2%)
10(9.8%)
102 (100.0%) 0 (0.0%)
22 Manometría: Diagnostico chicago 4.0 [character]
1. acalasia
2. MEI
3. normal
4. OTS
1(1.0%)
13(12.7%)
86(84.3%)
2(2.0%)
102 (100.0%) 0 (0.0%)
23 ...24 [character]
1. doble presion hernia
2. doble zona, hernia hiatal
3. en posición vertical es m
4. hernia hiatal
5. hernia hiatal 3,8 cm
6. hernia hiatal verificar I
7. LLAMAR A PACIENTE
8. no pasó la unión
9. no tolera posicion secund
10. rectificar presion intrag
1(3.8%)
1(3.8%)
1(3.8%)
15(57.7%)
1(3.8%)
1(3.8%)
1(3.8%)
3(11.5%)
1(3.8%)
1(3.8%)
26 (25.5%) 76 (74.5%)

Generated by summarytools 1.1.4 (R version 4.4.2)
2025-09-01

Cruce entre sintomas principales y sencudarios

print(
  ctable(
    x = BASE$`Síntoma principal`, 
    y = BASE$`Sintomas secundario`, 
    prop = "r"
  ),
  method = "render",
  headings = F,
  footnote = NA
)
`Sintomas secundario`
`Síntoma principal` disfagia dolor
toracico
globus regurgitacio
n
<NA> Total
disfagia 0 ( 0.0% ) 0 ( 0.0% ) 1 ( 12.5% ) 1 ( 12.5% ) 6 ( 75.0% ) 8 ( 100.0% )
dolor toracico 1 ( 33.3% ) 0 ( 0.0% ) 0 ( 0.0% ) 0 ( 0.0% ) 2 ( 66.7% ) 3 ( 100.0% )
emesis 0 ( 0.0% ) 0 ( 0.0% ) 0 ( 0.0% ) 0 ( 0.0% ) 1 ( 100.0% ) 1 ( 100.0% )
pirosis 11 ( 40.7% ) 4 ( 14.8% ) 0 ( 0.0% ) 3 ( 11.1% ) 9 ( 33.3% ) 27 ( 100.0% )
regurgitacion 1 ( 7.7% ) 2 ( 15.4% ) 0 ( 0.0% ) 0 ( 0.0% ) 10 ( 76.9% ) 13 ( 100.0% )
<NA> 0 ( 0.0% ) 0 ( 0.0% ) 0 ( 0.0% ) 0 ( 0.0% ) 50 ( 100.0% ) 50 ( 100.0% )
Total 13 ( 12.7% ) 6 ( 5.9% ) 1 ( 1.0% ) 4 ( 3.9% ) 78 ( 76.5% ) 102 ( 100.0% )

Cruces por tipo de cirugía

Variable sociodemograficas
level Overall 1 bypass/ Y Roux Control Manga gástrica p test
n 102 18 50 34
Edad mean SD 54.67 (11.98) 57.39 (10.72) 57.50 (12.37) 49.06 (10.19) 0.003
Genero femenino 84 (82.4) 16 (88.9) 40 (80.0) 28 (82.4) 0.698
X masculino 18 (17.6) 2 (11.1) 10 (20.0) 6 (17.6)
Síntoma principal disfagia 8 (15.4) 5 (27.8) 0 (NaN) 3 (8.8) NaN
X 1 dolor toracico 3 (5.8) 0 (0.0) 0 (NaN) 3 (8.8)
X 2 emesis 1 (1.9) 1 (5.6) 0 (NaN) 0 (0.0)
X 3 pirosis 27 (51.9) 9 (50.0) 0 (NaN) 18 (52.9)
X 4 regurgitacion 13 (25.0) 3 (16.7) 0 (NaN) 10 (29.4)
IMC Índice de masa corporalmean SD 24.29 (4.18) 26.33 (3.97) 21.28 (1.14) 27.65 (3.98) <0.001
Diagnostico en endoscopia Hernia hiatal 37 (36.6) 10 (58.8) 0 (0.0) 27 (79.4) <0.001
X 5 otro 64 (63.4) 7 (41.2) 50 (100.0) 7 (20.6)
Tiempo en años desde la cirugía bariátrica hasta el inicio de síntomas mean SD 6.79 (3.71) 7.60 (5.10) NaN (NA) 6.21 (2.33) 0.378
Manometría DCI promedio mean SD 1712.92 (1795.69) 1181.28 (966.50) 1705.08 (1258.23) 2005.91 (2606.58) 0.292
Manometría IRP mean SD 8.58 (6.05) 12.68 (10.50) 6.70 (4.24) 9.18 (3.68) 0.001
Manometría Presión intragástrica mayor a 30 mm Hg 58 (56.9) 1 (5.6) 49 (98.0) 8 (23.5) <0.001
X 6 menor a 30 mm Hg 44 (43.1) 17 (94.4) 1 (2.0) 26 (76.5)
Manometría Presión basal del LES mean SD 23.36 (11.73) 29.59 (16.14) 22.99 (10.30) 20.62 (10.01) 0.029
Presión intrabolo mayor a 20 mm Hg 27 (26.5) 5 (27.8) 1 (2.0) 21 (61.8) <0.001
X 7 menor a 20 mm Hg 75 (73.5) 13 (72.2) 49 (98.0) 13 (38.2)
Aclaramiento del bolo Completo 81 (83.5) 8 (53.3) 50 (100.0) 23 (71.9) <0.001
X 8 Incompleto 16 (16.5) 7 (46.7) 0 (0.0) 9 (28.1)
Manometría Presurización pan esofágica en isocontorno de 20 mm Hg No 99 (97.1) 17 (94.4) 50 (100.0) 32 (94.1) 0.226
X 9 Si 3 (2.9) 1 (5.6) 0 (0.0) 2 (5.9)
Manometría IRP en la prueba de RDC mean SD 2.53 (5.47) 6.56 (12.09) 1.66 (1.72) 1.76 (1.91) 0.003
Manometría Test de reserva peristáltica Adecuado 79 (77.5) 11 (61.1) 47 (94.0) 21 (61.8) <0.001
X 10 Inadecuado 23 (22.5) 7 (38.9) 3 (6.0) 13 (38.2)
Manometría Ausencia de inhibición deglutoria No 92 (90.2) 13 (72.2) 48 (96.0) 31 (91.2) 0.014
X 11 Si 10 (9.8) 5 (27.8) 2 (4.0) 3 (8.8)
Manometría Diagnostico chicago 4 0 acalasia 1 (1.0) 1 (5.6) 0 (0.0) 0 (0.0) <0.001
X 12 MEI 13 (12.7) 4 (22.2) 0 (0.0) 9 (26.5)
X 13 normal 86 (84.3) 11 (61.1) 50 (100.0) 25 (73.5)
X 14 OTS 2 (2.0) 2 (11.1) 0 (0.0) 0 (0.0)

Cruce por tipo de cirugías

BASE_cir <- BASE %>% filter(`Tipo de cirugía bariátrica` != "Control")


myVars2 <- c("Manometría: DCI promedio", "Manometría: IRP", "Manometría: Presión intragástrica", "Manometría: Presión basal del LES", "Presión intrabolo", "Aclaramiento del bolo", "Manometría: Presurización pan esofágica en isocontorno de 20 mm Hg", "Manometría: IRP en la prueba de RDC", "Manometría: Test de reserva peristáltica", "Manometría: Ausencia de inhibición deglutoria", "Manometría: Diagnostico chicago 4.0")

catVars2 <-  c( "Manometría: Presión intragástrica", "Presión intrabolo", "Aclaramiento del bolo", "Manometría: Presurización pan esofágica en isocontorno de 20 mm Hg",  "Manometría: Test de reserva peristáltica", "Manometría: Ausencia de inhibición deglutoria", "Manometría: Diagnostico chicago 4.0")

library(tableone)
tab2 <- CreateTableOne(vars = myVars2, factorVars= catVars2, data = BASE_cir,strata = "Tipo de cirugía bariátrica", includeNA = F, addOverall = T, testNonNormal = T)

table2 <- as.data.frame(print(tab1, showAllLevels= TRUE, printToggle = FALSE, noSpaces = TRUE))
rownames(table2) <- gsub("\\.{3,}", "", rownames(table2))  # Quita puntos suspensivos "..."
rownames(table2) <- gsub("\\.{1,}", "_", rownames(table2))  # Quita puntos suspensivos "..."
rownames(table2) <- gsub("\\_{1,}", " ", rownames(table2))  # Quita puntos suspensivos "..."


library(knitr)
library(kableExtra)

kable(table2, format = "html", caption = "Variable sociodemograficas") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = F,position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "black") %>%
  column_spec(2, border_left = T, color = "white", background = "grey")
Variable sociodemograficas
level Overall 1 bypass/ Y Roux Control Manga gástrica p test
n 102 18 50 34
Edad mean SD 54.67 (11.98) 57.39 (10.72) 57.50 (12.37) 49.06 (10.19) 0.003
Genero femenino 84 (82.4) 16 (88.9) 40 (80.0) 28 (82.4) 0.698
X masculino 18 (17.6) 2 (11.1) 10 (20.0) 6 (17.6)
Síntoma principal disfagia 8 (15.4) 5 (27.8) 0 (NaN) 3 (8.8) NaN
X 1 dolor toracico 3 (5.8) 0 (0.0) 0 (NaN) 3 (8.8)
X 2 emesis 1 (1.9) 1 (5.6) 0 (NaN) 0 (0.0)
X 3 pirosis 27 (51.9) 9 (50.0) 0 (NaN) 18 (52.9)
X 4 regurgitacion 13 (25.0) 3 (16.7) 0 (NaN) 10 (29.4)
IMC Índice de masa corporalmean SD 24.29 (4.18) 26.33 (3.97) 21.28 (1.14) 27.65 (3.98) <0.001
Diagnostico en endoscopia Hernia hiatal 37 (36.6) 10 (58.8) 0 (0.0) 27 (79.4) <0.001
X 5 otro 64 (63.4) 7 (41.2) 50 (100.0) 7 (20.6)
Tiempo en años desde la cirugía bariátrica hasta el inicio de síntomas mean SD 6.79 (3.71) 7.60 (5.10) NaN (NA) 6.21 (2.33) 0.378
Manometría DCI promedio mean SD 1712.92 (1795.69) 1181.28 (966.50) 1705.08 (1258.23) 2005.91 (2606.58) 0.292
Manometría IRP mean SD 8.58 (6.05) 12.68 (10.50) 6.70 (4.24) 9.18 (3.68) 0.001
Manometría Presión intragástrica mayor a 30 mm Hg 58 (56.9) 1 (5.6) 49 (98.0) 8 (23.5) <0.001
X 6 menor a 30 mm Hg 44 (43.1) 17 (94.4) 1 (2.0) 26 (76.5)
Manometría Presión basal del LES mean SD 23.36 (11.73) 29.59 (16.14) 22.99 (10.30) 20.62 (10.01) 0.029
Presión intrabolo mayor a 20 mm Hg 27 (26.5) 5 (27.8) 1 (2.0) 21 (61.8) <0.001
X 7 menor a 20 mm Hg 75 (73.5) 13 (72.2) 49 (98.0) 13 (38.2)
Aclaramiento del bolo Completo 81 (83.5) 8 (53.3) 50 (100.0) 23 (71.9) <0.001
X 8 Incompleto 16 (16.5) 7 (46.7) 0 (0.0) 9 (28.1)
Manometría Presurización pan esofágica en isocontorno de 20 mm Hg No 99 (97.1) 17 (94.4) 50 (100.0) 32 (94.1) 0.226
X 9 Si 3 (2.9) 1 (5.6) 0 (0.0) 2 (5.9)
Manometría IRP en la prueba de RDC mean SD 2.53 (5.47) 6.56 (12.09) 1.66 (1.72) 1.76 (1.91) 0.003
Manometría Test de reserva peristáltica Adecuado 79 (77.5) 11 (61.1) 47 (94.0) 21 (61.8) <0.001
X 10 Inadecuado 23 (22.5) 7 (38.9) 3 (6.0) 13 (38.2)
Manometría Ausencia de inhibición deglutoria No 92 (90.2) 13 (72.2) 48 (96.0) 31 (91.2) 0.014
X 11 Si 10 (9.8) 5 (27.8) 2 (4.0) 3 (8.8)
Manometría Diagnostico chicago 4 0 acalasia 1 (1.0) 1 (5.6) 0 (0.0) 0 (0.0) <0.001
X 12 MEI 13 (12.7) 4 (22.2) 0 (0.0) 9 (26.5)
X 13 normal 86 (84.3) 11 (61.1) 50 (100.0) 25 (73.5)
X 14 OTS 2 (2.0) 2 (11.1) 0 (0.0) 0 (0.0)
library(openxlsx)
write.xlsx(table2, "tabla1.xlsx", rowNames = TRUE)

Verificar en donde está la diferencia entre las variables cuantitativas

#Pruebas de normalidad
library(broom)
library(tidyr)
library(purrr)
library(dplyr)


tabla_shapiro <- BASE %>%
  group_by(`Tipo de cirugía bariátrica`) %>%
  summarise(
    shapiro = list(shapiro.test(Edad)),
    .groups = "drop"
  ) %>%
  mutate(shapiro = map(shapiro, tidy)) %>%
  unnest(shapiro)


library(gt)
tabla_shapiro %>%
  gt() %>%
  tab_header(
    title = md("**Prueba de normalidad Shapiro-Wilk EDAD por tipo de cirugía**"),
    subtitle = "Resultados agrupados"
  ) %>%
  tab_style(
    style = cell_text(align = "center", weight = "bold", color = "darkblue"),
    locations = cells_column_labels(everything())
  ) %>%
  tab_style(
    style = cell_text(align = "center"),
    locations = cells_body(columns = everything())
  ) %>%
  fmt_number(
    columns = where(is.numeric),
    decimals = 4
  ) %>%
  opt_table_outline() %>%
  opt_row_striping()
Prueba de normalidad Shapiro-Wilk EDAD por tipo de cirugía
Resultados agrupados
Tipo de cirugía bariátrica statistic p.value method
1 bypass/ Y Roux 0.9522 0.4598 Shapiro-Wilk normality test
Control 0.9541 0.0504 Shapiro-Wilk normality test
Manga gástrica 0.9654 0.3464 Shapiro-Wilk normality test

Comparación por pares

library(FSA)

# Correr la prueba de Dunn
dunn_res <- dunnTest(Edad ~ `Tipo de cirugía bariátrica`, 
                     data = BASE, 
                     method = "bonferroni")

# Extraer la tabla de resultados
tabla_dunn <- dunn_res$res

# Pasar a gt para embellecer
tabla_dunn %>%
  gt() %>%
  tab_header(
    title = "Prueba de Dunn post-hoc EDAD",
    subtitle = "Ajuste por Bonferroni"
  ) %>%
  cols_label(
    Comparison = "Comparación",
    Z          = "Estadístico Z",
    P.unadj    = "p-valor sin ajuste",
    P.adj      = "p-valor ajustado"
  ) %>%
  fmt_number(
    columns = c(Z, P.unadj, P.adj),
    decimals = 4
  ) %>%
  tab_style(
    style = list(
      cell_text(weight = "bold", align = "center")
    ),
    locations = cells_column_labels(everything())
  )
Prueba de Dunn post-hoc EDAD
Ajuste por Bonferroni
Comparación Estadístico Z p-valor sin ajuste p-valor ajustado
1 bypass/ Y Roux - Control −0.2125 0.8317 1.0000
1 bypass/ Y Roux - Manga gástrica 2.2382 0.0252 0.0756
Control - Manga gástrica 3.1977 0.0014 0.0042

La diferencia esta entre: “Control - Manga gástrica y”1 bypass/Roux - Manga gástrica”

tabla_shapiro2 <- BASE %>%
  group_by(`Tipo de cirugía bariátrica`) %>%
  summarise(
    shapiro = list(shapiro.test(`IMC (Índice de masa corporal)`)),
    .groups = "drop"
  ) %>%
  mutate(shapiro = map(shapiro, tidy)) %>%
  unnest(shapiro)


library(gt)
tabla_shapiro2 %>%
  gt() %>%
  tab_header(
    title = md("**Prueba de normalidad Shapiro-Wilk IMC por tipo de cirugía**"),
    subtitle = "Resultados agrupados"
  ) %>%
  tab_style(
    style = cell_text(align = "center", weight = "bold", color = "darkblue"),
    locations = cells_column_labels(everything())
  ) %>%
  tab_style(
    style = cell_text(align = "center"),
    locations = cells_body(columns = everything())
  ) %>%
  fmt_number(
    columns = where(is.numeric),
    decimals = 4
  ) %>%
  opt_table_outline() %>%
  opt_row_striping()
Prueba de normalidad Shapiro-Wilk IMC por tipo de cirugía
Resultados agrupados
Tipo de cirugía bariátrica statistic p.value method
1 bypass/ Y Roux 0.9422 0.3154 Shapiro-Wilk normality test
Control 0.9275 0.0044 Shapiro-Wilk normality test
Manga gástrica 0.9501 0.1236 Shapiro-Wilk normality test
dunn_res2 <- dunnTest(`IMC (Índice de masa corporal)` ~ `Tipo de cirugía bariátrica`, 
                     data = BASE, 
                     method = "bonferroni")

tabla_dunn2 <- dunn_res2$res

tabla_dunn2 %>%
  gt() %>%
  tab_header(
    title = "Prueba de Dunn post-hoc IMC",
    subtitle = "Ajuste por Bonferroni"
  ) %>%
  cols_label(
    Comparison = "Comparación",
    Z          = "Estadístico Z",
    P.unadj    = "p-valor sin ajuste",
    P.adj      = "p-valor ajustado"
  ) %>%
  fmt_number(
    columns = c(Z, P.unadj, P.adj),
    decimals = 4
  ) %>%
  tab_style(
    style = list(
      cell_text(weight = "bold", align = "center")
    ),
    locations = cells_column_labels(everything())
  )
Prueba de Dunn post-hoc IMC
Ajuste por Bonferroni
Comparación Estadístico Z p-valor sin ajuste p-valor ajustado
1 bypass/ Y Roux - Control 4.8624 0.0000 0.0000
1 bypass/ Y Roux - Manga gástrica −1.0006 0.3170 0.9511
Control - Manga gástrica −7.3247 0.0000 0.0000

Diferencias entre: 1 bypass/ Y Roux - Control & Control - Manga gástrica

tabla_shapiro3 <- BASE %>%
  group_by(`Tipo de cirugía bariátrica`) %>%
  summarise(
    shapiro = list(shapiro.test(`Manometría: IRP`)),
    .groups = "drop"
  ) %>%
  mutate(shapiro = map(shapiro, tidy)) %>%
  unnest(shapiro)

tabla_shapiro3 %>%
  gt() %>%
  tab_header(
    title = md("**Prueba de normalidad Shapiro-Wilk Manometría: IRP por tipo de cirugía**"),
    subtitle = "Resultados agrupados"
  ) %>%
  tab_style(
    style = cell_text(align = "center", weight = "bold", color = "darkblue"),
    locations = cells_column_labels(everything())
  ) %>%
  tab_style(
    style = cell_text(align = "center"),
    locations = cells_body(columns = everything())
  ) %>%
  fmt_number(
    columns = where(is.numeric),
    decimals = 4
  ) %>%
  opt_table_outline() %>%
  opt_row_striping()
Prueba de normalidad Shapiro-Wilk Manometría: IRP por tipo de cirugía
Resultados agrupados
Tipo de cirugía bariátrica statistic p.value method
1 bypass/ Y Roux 0.7717 0.0006 Shapiro-Wilk normality test
Control 0.9132 0.0014 Shapiro-Wilk normality test
Manga gástrica 0.9488 0.1129 Shapiro-Wilk normality test
dunn_res3 <- dunnTest(`Manometría: IRP` ~ `Tipo de cirugía bariátrica`, 
                     data = BASE, 
                     method = "bonferroni")

# Extraer la tabla de resultados
tabla_dunn3 <- dunn_res3$res

# Pasar a gt para embellecer
tabla_dunn3 %>%
  gt() %>%
  tab_header(
    title = "Prueba de Dunn post-hoc Manometría: IRP",
    subtitle = "Ajuste por Bonferroni"
  ) %>%
  cols_label(
    Comparison = "Comparación",
    Z          = "Estadístico Z",
    P.unadj    = "p-valor sin ajuste",
    P.adj      = "p-valor ajustado"
  ) %>%
  fmt_number(
    columns = c(Z, P.unadj, P.adj),
    decimals = 4
  ) %>%
  tab_style(
    style = list(
      cell_text(weight = "bold", align = "center")
    ),
    locations = cells_column_labels(everything())
  )
Prueba de Dunn post-hoc Manometría: IRP
Ajuste por Bonferroni
Comparación Estadístico Z p-valor sin ajuste p-valor ajustado
1 bypass/ Y Roux - Control 2.9262 0.0034 0.0103
1 bypass/ Y Roux - Manga gástrica 0.5224 0.6014 1.0000
Control - Manga gástrica −2.9335 0.0034 0.0101

Diferencias entre: 1 bypass/ Y Roux - Control & Control - Manga gástrica

tabla_shapiro4 <- BASE %>%
  group_by(`Tipo de cirugía bariátrica`) %>%
  summarise(
    shapiro = list(shapiro.test(`Manometría: Presión basal del LES`)),
    .groups = "drop"
  ) %>%
  mutate(shapiro = map(shapiro, tidy)) %>%
  unnest(shapiro)

tabla_shapiro4 %>%
  gt() %>%
  tab_header(
    title = md("**Prueba de normalidad Shapiro-Wilk Manometría: Presión basal del LES por tipo de cirugía**"),
    subtitle = "Resultados agrupados"
  ) %>%
  tab_style(
    style = cell_text(align = "center", weight = "bold", color = "darkblue"),
    locations = cells_column_labels(everything())
  ) %>%
  tab_style(
    style = cell_text(align = "center"),
    locations = cells_body(columns = everything())
  ) %>%
  fmt_number(
    columns = where(is.numeric),
    decimals = 4
  ) %>%
  opt_table_outline() %>%
  opt_row_striping()
Prueba de normalidad Shapiro-Wilk Manometría: Presión basal del LES por tipo de cirugía
Resultados agrupados
Tipo de cirugía bariátrica statistic p.value method
1 bypass/ Y Roux 0.8772 0.0234 Shapiro-Wilk normality test
Control 0.9614 0.1015 Shapiro-Wilk normality test
Manga gástrica 0.9375 0.0519 Shapiro-Wilk normality test
dunn_res4 <- dunnTest(`Manometría: Presión basal del LES` ~ `Tipo de cirugía bariátrica`, 
                     data = BASE, 
                     method = "bonferroni")

# Extraer la tabla de resultados
tabla_dunn4 <- dunn_res4$res

# Pasar a gt para embellecer
tabla_dunn4 %>%
  gt() %>%
  tab_header(
    title = "Prueba de Dunn post-hoc Manometría: Presión basal del LES",
    subtitle = "Ajuste por Bonferroni"
  ) %>%
  cols_label(
    Comparison = "Comparación",
    Z          = "Estadístico Z",
    P.unadj    = "p-valor sin ajuste",
    P.adj      = "p-valor ajustado"
  ) %>%
  fmt_number(
    columns = c(Z, P.unadj, P.adj),
    decimals = 4
  ) %>%
  tab_style(
    style = list(
      cell_text(weight = "bold", align = "center")
    ),
    locations = cells_column_labels(everything())
  )
Prueba de Dunn post-hoc Manometría: Presión basal del LES
Ajuste por Bonferroni
Comparación Estadístico Z p-valor sin ajuste p-valor ajustado
1 bypass/ Y Roux - Control 1.4230 0.1547 0.4642
1 bypass/ Y Roux - Manga gástrica 2.1428 0.0321 0.0964
Control - Manga gástrica 1.0502 0.2936 0.8809

Hubo “mayo diferencia” entre: 1 bypass/ Y Roux - Manga gástrica

tabla_shapiro5 <- BASE %>%
  group_by(`Tipo de cirugía bariátrica`) %>%
  summarise(
    shapiro = list(shapiro.test(`Manometría: IRP en la prueba de RDC`)),
    .groups = "drop"
  ) %>%
  mutate(shapiro = map(shapiro, tidy)) %>%
  unnest(shapiro)

tabla_shapiro5 %>%
  gt() %>%
  tab_header(
    title = md("**Prueba de normalidad Shapiro-Wilk `Manometría: IRP en la prueba de RDC` por tipo de cirugía**"),
    subtitle = "Resultados agrupados"
  ) %>%
  tab_style(
    style = cell_text(align = "center", weight = "bold", color = "darkblue"),
    locations = cells_column_labels(everything())
  ) %>%
  tab_style(
    style = cell_text(align = "center"),
    locations = cells_body(columns = everything())
  ) %>%
  fmt_number(
    columns = where(is.numeric),
    decimals = 4
  ) %>%
  opt_table_outline() %>%
  opt_row_striping()
Prueba de normalidad Shapiro-Wilk Manometría: IRP en la prueba de RDC por tipo de cirugía
Resultados agrupados
Tipo de cirugía bariátrica statistic p.value method
1 bypass/ Y Roux 0.5911 0.0000 Shapiro-Wilk normality test
Control 0.7838 0.0000 Shapiro-Wilk normality test
Manga gástrica 0.8205 0.0001 Shapiro-Wilk normality test
dunn_res5 <- dunnTest(`Manometría: IRP en la prueba de RDC` ~ `Tipo de cirugía bariátrica`, 
                     data = BASE, 
                     method = "bonferroni")

tabla_dunn5 <- dunn_res5$res

tabla_dunn5 %>%
  gt() %>%
  tab_header(
    title = "Prueba de Dunn post-hoc Manometría: IRP en la prueba de RDC",
    subtitle = "Ajuste por Bonferroni"
  ) %>%
  cols_label(
    Comparison = "Comparación",
    Z          = "Estadístico Z",
    P.unadj    = "p-valor sin ajuste",
    P.adj      = "p-valor ajustado"
  ) %>%
  fmt_number(
    columns = c(Z, P.unadj, P.adj),
    decimals = 4
  ) %>%
  tab_style(
    style = list(
      cell_text(weight = "bold", align = "center")
    ),
    locations = cells_column_labels(everything())
  )
Prueba de Dunn post-hoc Manometría: IRP en la prueba de RDC
Ajuste por Bonferroni
Comparación Estadístico Z p-valor sin ajuste p-valor ajustado
1 bypass/ Y Roux - Control 0.7374 0.4609 1.0000
1 bypass/ Y Roux - Manga gástrica 0.9299 0.3524 1.0000
Control - Manga gástrica 0.3183 0.7503 1.0000
pairwise.t.test(x = BASE$`Manometría: IRP en la prueba de RDC`, 
                g = BASE$`Tipo de cirugía bariátrica`, 
                p.adjust.method = "bonferroni")
## 
##  Pairwise comparisons using t tests with pooled SD 
## 
## data:  BASE$`Manometría: IRP en la prueba de RDC` and BASE$`Tipo de cirugía bariátrica` 
## 
##                1 bypass/ Y Roux Control
## Control        0.0034           -      
## Manga gástrica 0.0082           1.0000 
## 
## P value adjustment method: bonferroni

No se encontraron diferencias especificas

Analisis global escalas BED-Q

#dput(names(BASE_BED_Q))
myVars3 <- c("Total", "Mayor o igual a 1")

catVars3 <-  c("Mayor o igual a 1")

tab3 <- CreateTableOne(vars = myVars3, factorVars= catVars3, data = BASE_BED_Q,strata = "Tipo de cirugía bariátrica", includeNA = F, addOverall = T, testNonNormal = T)

table3 <- as.data.frame(print(tab2, showAllLevels= TRUE, printToggle = FALSE, noSpaces = TRUE))
rownames(table3) <- gsub("\\.{3,}", "", rownames(table3))  # Quita puntos suspensivos "..."
rownames(table3) <- gsub("\\.{1,}", "_", rownames(table3))  # Quita puntos suspensivos "..."
rownames(table3) <- gsub("\\_{1,}", " ", rownames(table3))  # Quita puntos suspensivos "..."


kable(table3, format = "html", caption = "BED-Q") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = F,position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "black") %>%
  column_spec(2, border_left = T, color = "white", background = "grey")
BED-Q
level Overall 1 bypass/ Y Roux Manga gástrica p test
n 52 18 34
Manometría DCI promedio mean SD 1720.46 (2205.58) 1181.28 (966.50) 2005.91 (2606.58) 0.203
Manometría IRP mean SD 10.39 (6.96) 12.68 (10.50) 9.18 (3.68) 0.084
Manometría Presión intragástrica mayor a 30 mm Hg 9 (17.3) 1 (5.6) 8 (23.5) 0.213
X menor a 30 mm Hg 43 (82.7) 17 (94.4) 26 (76.5)
Manometría Presión basal del LES mean SD 23.73 (13.05) 29.59 (16.14) 20.62 (10.01) 0.017
Presión intrabolo mayor a 20 mm Hg 26 (50.0) 5 (27.8) 21 (61.8) 0.041
X 1 menor a 20 mm Hg 26 (50.0) 13 (72.2) 13 (38.2)
Aclaramiento del bolo Completo 31 (66.0) 8 (53.3) 23 (71.9) 0.357
X 2 Incompleto 16 (34.0) 7 (46.7) 9 (28.1)
Manometría Presurización pan esofágica en isocontorno de 20 mm Hg No 49 (94.2) 17 (94.4) 32 (94.1) 1.000
X 3 Si 3 (5.8) 1 (5.6) 2 (5.9)
Manometría IRP en la prueba de RDC mean SD 3.42 (7.51) 6.56 (12.09) 1.76 (1.91) 0.032
Manometría Test de reserva peristáltica Adecuado 32 (61.5) 11 (61.1) 21 (61.8) 1.000
X 4 Inadecuado 20 (38.5) 7 (38.9) 13 (38.2)
Manometría Ausencia de inhibición deglutoria No 44 (84.6) 13 (72.2) 31 (91.2) 0.162
X 5 Si 8 (15.4) 5 (27.8) 3 (8.8)
Manometría Diagnostico chicago 4 0 acalasia 1 (1.9) 1 (5.6) 0 (0.0) 0.111
X 6 MEI 13 (25.0) 4 (22.2) 9 (26.5)
X 7 normal 36 (69.2) 11 (61.1) 25 (73.5)
X 8 OTS 2 (3.8) 2 (11.1) 0 (0.0)

Prueba de diferencia de proporciones “Mayor o igual a 1”

prop.test(c(13, 17), c(18, 36))
## 
##  2-sample test for equality of proportions with continuity correction
## 
## data:  c(13, 17) out of c(18, 36)
## X-squared = 2.1094, df = 1, p-value = 0.1464
## alternative hypothesis: two.sided
## 95 percent confidence interval:
##  -0.05512269  0.55512269
## sample estimates:
##    prop 1    prop 2 
## 0.7222222 0.4722222

No hubo diferencias esatdísticamente significativas entre las proporciones.

Analisis global escalas GERD-Q

#pROBANDO IGUAL O MAYOR A 8 
BASE_GERDQ <- BASE_GERDQ %>% 
  mutate(`Sintomas >=8` = cut(
    Total,
    breaks = c(-Inf, 8, Inf),
    right = FALSE,
    labels = c("Menor a 8", "Mayor o igual a 8")
  ))

#dput(names(BASE_GERDQ))


myVars4 <- c("Total", "Sintomas >1", "Sintomas >=8", "Hernia hiatal")

catVars4 <-  c("Sintomas >1", "Sintomas >=8", "Hernia hiatal")

tab4 <- CreateTableOne(vars = myVars4, factorVars= catVars4, data = BASE_GERDQ,strata = "Tipo de cirugia bariatrica", includeNA = F, addOverall = T, testNonNormal = T)

table4 <- as.data.frame(print(tab4, showAllLevels= TRUE, printToggle = FALSE, noSpaces = TRUE))
rownames(table4) <- gsub("\\.{3,}", "", rownames(table4))  # Quita puntos suspensivos "..."
rownames(table4) <- gsub("\\.{1,}", "_", rownames(table4))  # Quita puntos suspensivos "..."
rownames(table4) <- gsub("\\_{1,}", " ", rownames(table4))  # Quita puntos suspensivos "..."


kable(table4, format = "html", caption = "GERDQ") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = F,position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "black") %>%
  column_spec(2, border_left = T, color = "white", background = "grey")
GERDQ
level Overall 1 bypass/ Y Roux Manga gástrica p test
n 55 18 36
Total mean SD 6.31 (4.67) 6.39 (3.82) 5.94 (4.75) 0.732
Sintomas 1 No 10 (18.2) 3 (16.7) 7 (19.4) 1.000
X Si 45 (81.8) 15 (83.3) 29 (80.6)
Sintomas8 Menor a 8 37 (67.3) 12 (66.7) 25 (69.4) 1.000
X 1 Mayor o igual a 8 18 (32.7) 6 (33.3) 11 (30.6)
Hernia hiatal 0 1 (1.9) 1 (5.6) 0 (0.0) 0.179
X 2 Hernia hiatal 37 (68.5) 10 (55.6) 27 (75.0)
X 3 otro 16 (29.6) 7 (38.9) 9 (25.0)

Comparando las medianas del totoal de sintomas

aggregate(Total ~ `Tipo de cirugia bariatrica`, 
          data = BASE_GERDQ, 
          FUN = median) |>
  gt() |>
  tab_header(
    title = "Mediana del Total según tipo de cirugía bariátrica"
  )
Mediana del Total según tipo de cirugía bariátrica
Tipo de cirugia bariatrica Total
1 bypass/ Y Roux 6
Manga gástrica 5

Realizando el box plot

library(ggplot2)
library(ggpubr)

boxplotab <- ggboxplot(BASE_GERDQ, 
                       x = "Tipo de cirugia bariatrica", 
                       y = "Total", 
                       color = "Tipo de cirugia bariatrica", 
                       palette = "jco", 
                       add = "jitter", 
                       outlier.shape = NA,   # oculta outliers si quieres
                       width = 0.6,
                       lwd = 1.3) +          # grosor de la línea del boxplot
  theme_minimal(base_size = 14) +
  theme(
    axis.text.x = element_text(angle = 0, hjust = 1, face = "bold", color = "black"),
    axis.text.y = element_text(face = "bold", color = "black"),
    legend.position = "none",
    plot.title = element_text(face = "bold", hjust = 0.5)
  ) +
  scale_y_continuous(breaks = seq(0, max(BASE_GERDQ$Total, na.rm = TRUE), by = 5)) +
  scale_x_discrete(drop = TRUE) +
  labs(
    title = "Distribución del puntaje GERDQ según tipo de cirugía bariátrica",
    x = "Tipo de cirugía bariátrica",
    y = "Puntaje total GERDQ"
  )

boxplotab