Preparación base de datos

  1. Codificación variable tratamiento y edad
  2. Codificación variable ocupación
  3. Codificación variable religión
  4. Diagnósticos
  5. Recodificando tipo de MAC no detectable con una sola variable
  6. Rocidificando el tipo de MAC acorde a las nuevas agrupaciones
library(readxl)
GAT <- read_excel("GAT.xlsx")
#se unifican las variables antes y después del diagnóstico por tipo de tratamiento. 

#1
library(dplyr)
GAT <- GAT %>% 
  mutate(QUIM = ifelse(AQuimioTerSiste == "Checked" | BQuimioTerSiste == "Checked", "Si", "No")) %>% 
  mutate(RAD = ifelse(ARadio == "Checked" | BRadio == "Checked", "Si", "No")) %>% 
  mutate(CIR = ifelse(ACirugia == "Checked" | BCirugia == "Checked", "Si", "No")) %>% 
  mutate(PAL = ifelse(APaliativo == "Checked" | BPaliativo == "Checked", "Si", "No"))


GAT <- GAT %>% mutate(Edadcat = cut(Edad, breaks = c(-Inf, 49, 64, Inf), right = F, labels = c("< 50 años", "50 - 64 años", ">=65")))

#2
GAT$Nocup <- ifelse(GAT$Ocupacion %in% c("Cesante"), "Cesante",
                    ifelse(GAT$Ocupacion %in% c("Estudiante"), "Estudiante", 
                    ifelse(GAT$Ocupacion %in% c("Empleado", "Independiente"), "Empleado/Independiente",
                    ifelse(GAT$Ocupacion %in% c("Hogar", "Pensionado"), "Hogar/Pensionado",GAT$Ocupacion))))


#3 
GAT$Nrel <- ifelse(GAT$Religion %in% c("Católica"), "Católica",
                    ifelse(GAT$Religion %in% c("Cristiana"), "Cristiana", 
                    ifelse(GAT$Religion %in% c("Judía", "No profesa religión", "Otra"), "Otra", GAT$Religion)))

#4
GAT$CIE <- ifelse(substr(GAT$TipoCancer, 1, 1) == "D", "D", substr(GAT$TipoCancer, 1, 3))
GAT$Tipotumor <- ifelse(GAT$CIE == "D", "hematologico", "tumor solido")


#5 

#Unificando el tipo de MAC que no se capta con un única respuesta
  #terapias de cuerpo

#mente cuerpo
GAT <- GAT %>%
  mutate(cuerpo = ifelse(rowSums(!is.na(select(., Masaje, Reflexología, Quiropraxia))) > 0 & rowSums(select(., Masaje, Reflexología, Quiropraxia) == "Si", na.rm = TRUE) > 0, 
"Si", "No"))

#terapia energetica
GAT <- GAT %>%
  mutate(energetica = ifelse(rowSums(!is.na(select(., Bioenergética, `Terapia electromagnética`, Acupuntura, TerapiaNeural))) > 0 & rowSums(select(., Bioenergética, `Terapia electromagnética`, Acupuntura, TerapiaNeural) == "Si", na.rm = TRUE) > 0, 
"Si", "No"))

#terapia mente
GAT <- GAT %>%
  mutate(mente = ifelse(rowSums(!is.na(select(., Meditacion, Yoga, Taichi, Yorae, OtroMente))) > 0 & rowSums(select(., Meditacion, Yoga, Taichi, Yorae, OtroMente) == "Checked", na.rm = TRUE) > 0, "Si", "No"))


#6 
GAT <- GAT %>% 
  mutate(Base_planta = ifelse(Planta == "Si" | Hierbas == "Si", "Si", "No")) %>% 
  mutate(Base_animal = ifelse(Animal == "Si" | OrigenAnimal == "Si", "Si", "No")) %>% 
  mutate(Nutricionales = ifelse(Dieta == "Si" | Vitaminas == "Si", "Si", "No")) %>% 
  mutate(whole = ifelse(Homeopatia == "Si" | Tradicionales == "Si" | cuerpo == "Si" | energetica == "Si" | mente == "Si", "Si", "No"))

Cruce de variables

Tratamientos

GAT$Sexo <- as.factor(GAT$Sexo)
GAT$Nrel <- as.factor(GAT$Nrel)
GAT$Nocup <- as.factor(GAT$Nocup)
GAT$QUIM <- as.factor(GAT$QUIM)
GAT$RAD <- as.factor(GAT$RAD)
GAT$PAL <- as.factor(GAT$PAL)
GAT$CIR <- as.factor(GAT$CIR)
GAT$Base_animal <- as.factor(GAT$Base_animal)
GAT$Base_planta <- as.factor(GAT$Base_planta)
GAT$Nutricionales <- as.factor(GAT$Nutricionales)
GAT$whole <- as.factor(GAT$whole)
GAT$EstadoCancer <- as.factor(GAT$EstadoCancer)
GAT$Tipotumor <- as.factor(GAT$Tipotumor)
GAT_MAC <- GAT %>% filter(AlternativaActual == "Si")
myVars1 <- c("Sexo", "Nocup", "Nrel", "Edadcat")
catVars1 <- c("Sexo", "Nocup", "Nrel", "Edadcat")

library(tableone)
table1 <- CreateTableOne(vars = myVars1, data = GAT_MAC, factorVars = catVars1, includeNA = FALSE, strata = "QUIM")
table2 <- CreateTableOne(vars = myVars1, data = GAT_MAC, factorVars = catVars1, includeNA = FALSE, strata = "RAD")
table3 <- CreateTableOne(vars = myVars1, data = GAT_MAC, factorVars = catVars1, includeNA = FALSE, strata = "CIR")
table4 <- CreateTableOne(vars = myVars1, data = GAT_MAC, factorVars = catVars1, includeNA = FALSE, strata = "PAL")
table1 <- as.data.frame(print(table1, show.all = TRUE, printToggle = FALSE))
table2 <- as.data.frame(print(table2, show.all = TRUE, printToggle = FALSE))
table3 <- as.data.frame(print(table3, show.all = TRUE, printToggle = FALSE))
table4 <- as.data.frame(print(table4, show.all = TRUE, printToggle = FALSE))


library(knitr)
library(kableExtra)
kable(table1, format = "html", caption = "Cruce Quim - VRBLS SOC_DEM.") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), 
                full_width = F, 
                position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "#D7261E") %>%
  column_spec(2, border_left = T, background = "#F3E6E3")
Cruce Quim - VRBLS SOC_DEM.
No Si p test
n 61 1549
Sexo = Masculino (%) 24 (39.3) 458 (29.6) 0.135
Nocup (%) 0.315
Cesante 7 (11.5) 156 (10.1)
Empleado/Independiente 19 (31.1) 495 (32.0)
Estudiante 2 ( 3.3) 14 ( 0.9)
Hogar/Pensionado 33 (54.1) 884 (57.1)
Nrel (%) 0.005
Católica 45 (73.8) 1177 (76.0)
Cristiana 6 ( 9.8) 273 (17.6)
Otra 10 (16.4) 99 ( 6.4)
Edadcat (%) 0.017
< 50 años 10 (16.4) 369 (23.8)
50 - 64 años 18 (29.5) 620 (40.0)
>=65 33 (54.1) 560 (36.2)
kable(table2, format = "html", caption = "Cruce RAD - VRBLS SOCIO_DEM.") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), 
                full_width = F, 
                position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "blue") %>%
  column_spec(2, border_left = T, background = "#ADD8E6")
Cruce RAD - VRBLS SOCIO_DEM.
No Si p test
n 1033 577
Sexo = Masculino (%) 313 (30.3) 169 (29.3) 0.713
Nocup (%) 0.210
Cesante 102 ( 9.9) 61 (10.6)
Empleado/Independiente 342 (33.1) 172 (29.8)
Estudiante 7 ( 0.7) 9 ( 1.6)
Hogar/Pensionado 582 (56.3) 335 (58.1)
Nrel (%) 0.013
Católica 765 (74.1) 457 (79.2)
Cristiana 185 (17.9) 94 (16.3)
Otra 83 ( 8.0) 26 ( 4.5)
Edadcat (%) 0.064
< 50 años 260 (25.2) 119 (20.6)
50 - 64 años 410 (39.7) 228 (39.5)
>=65 363 (35.1) 230 (39.9)
kable(table3, format = "html", caption = "Cruce CIR - VRBLS SOCIO_DEM.") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), 
                full_width = F, 
                position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "#698B22") %>%
  column_spec(2, border_left = T, background = "#98FB98")
Cruce CIR - VRBLS SOCIO_DEM.
No Si p test
n 782 828
Sexo = Masculino (%) 257 (32.9) 225 (27.2) 0.015
Nocup (%) 0.973
Cesante 78 (10.0) 85 (10.3)
Empleado/Independiente 252 (32.2) 262 (31.6)
Estudiante 7 ( 0.9) 9 ( 1.1)
Hogar/Pensionado 445 (56.9) 472 (57.0)
Nrel (%) 0.017
Católica 572 (73.1) 650 (78.5)
Cristiana 145 (18.5) 134 (16.2)
Otra 65 ( 8.3) 44 ( 5.3)
Edadcat (%) 0.089
< 50 años 202 (25.8) 177 (21.4)
50 - 64 años 295 (37.7) 343 (41.4)
>=65 285 (36.4) 308 (37.2)
kable(table4, format = "html", caption = "Cruce PAL - VRBLS SOCIO_DEM.") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), 
                full_width = F, 
                position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "#8B475D") %>%
  column_spec(2, border_left = T, background = "#FFC0CB")
Cruce PAL - VRBLS SOCIO_DEM.
No Si p test
n 1569 41
Sexo = Masculino (%) 466 (29.7) 16 (39.0) 0.265
Nocup (%) 0.012
Cesante 153 ( 9.8) 10 (24.4)
Empleado/Independiente 505 (32.2) 9 (22.0)
Estudiante 15 ( 1.0) 1 ( 2.4)
Hogar/Pensionado 896 (57.1) 21 (51.2)
Nrel (%) 0.104
Católica 1195 (76.2) 27 (65.9)
Cristiana 271 (17.3) 8 (19.5)
Otra 103 ( 6.6) 6 (14.6)
Edadcat (%) 0.005
< 50 años 374 (23.8) 5 (12.2)
50 - 64 años 627 (40.0) 11 (26.8)
>=65 568 (36.2) 25 (61.0)

Cruce diagnóstico

GAT_TRAT <- GAT %>% filter(EstadoCancer != "No sabe")
GAT_TRAT <- GAT_TRAT %>%
  mutate(EstadoCancer = case_when(
    EstadoCancer == "Con ganglios comprometidos, pero sin metástasis a otros órganos" | EstadoCancer == "Localizado" ~ "Localizado/Con ganglios comprometidos",
    EstadoCancer == "Con metástasis a otros órganos" ~ "Metastasis"
  ))
myVars2 <- c("Sexo", "Nocup", "Nrel", "Edadcat", "EstadoCancer", "Tipotumor")
catVars2 <- c("Sexo", "Nocup", "Nrel", "Edadcat", "EstadoCancer", "Tipotumor")
table5 <- CreateTableOne(vars = myVars2, data = GAT_TRAT, factorVars = catVars2, includeNA = FALSE, strata = "AlternativaActual", addOverall = TRUE)
table5 <- as.data.frame(print(table5, show.all = TRUE, printToggle = FALSE))
kable(table5, format = "html", caption = "Cruce MAC - VRBLS SOCIO_DEM.") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), 
                full_width = F, 
                position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "orange") %>%
  column_spec(2, border_left = T, background = "#EEDD82")
Cruce MAC - VRBLS SOCIO_DEM.
Overall No Si p test
n 2830 1365 1465
Sexo = Masculino (%) 1044 (36.9) 607 (44.5) 437 (29.8) <0.001
Nocup (%) <0.001
Cesante 362 (12.8) 223 (16.3) 139 ( 9.5)
Empleado/Independiente 857 (30.3) 379 (27.8) 478 (32.6)
Estudiante 28 ( 1.0) 12 ( 0.9) 16 ( 1.1)
Hogar/Pensionado 1583 (55.9) 751 (55.0) 832 (56.8)
Nrel (%) <0.001
Católica 2214 (78.2) 1104 (80.9) 1110 (75.8)
Cristiana 417 (14.7) 164 (12.0) 253 (17.3)
Otra 199 ( 7.0) 97 ( 7.1) 102 ( 7.0)
Edadcat (%) <0.001
< 50 años 638 (22.5) 277 (20.3) 361 (24.6)
50 - 64 años 1044 (36.9) 450 (33.0) 594 (40.5)
>=65 1148 (40.6) 638 (46.7) 510 (34.8)
EstadoCancer = Metastasis (%) 826 (29.2) 401 (29.4) 425 (29.0) 0.862
Tipotumor = tumor solido (%) 2750 (97.2) 1329 (97.4) 1421 (97.0) 0.636

Tipo de MAC

GAT_TRAT_MAC <- GAT_TRAT %>% filter(AlternativaActual == "Si")

table6 <- CreateTableOne(vars = myVars2, data = GAT_TRAT_MAC, factorVars = catVars2, includeNA = FALSE, strata = "Base_animal")
table7 <- CreateTableOne(vars = myVars2, data = GAT_TRAT_MAC, factorVars = catVars2, includeNA = FALSE, strata = "Base_planta")
table8 <- CreateTableOne(vars = myVars2, data = GAT_TRAT_MAC, factorVars = catVars2, includeNA = FALSE, strata = "Nutricionales")
table9 <- CreateTableOne(vars = myVars2, data = GAT_TRAT_MAC, factorVars = catVars2, includeNA = FALSE, strata = "whole")
table6 <- as.data.frame(print(table6, show.all = TRUE, printToggle = FALSE))
table7 <- as.data.frame(print(table7, show.all = TRUE, printToggle = FALSE))
table8 <- as.data.frame(print(table8, show.all = TRUE, printToggle = FALSE))
table9 <- as.data.frame(print(table9, show.all = TRUE, printToggle = FALSE))

kable(table6, format = "html", caption = "Cruce MAC ANIMAL - VRBLS SOCIO_DEM.") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), 
                full_width = F, 
                position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "#CD5555") %>%
  column_spec(2, border_left = T, background = "#CD8C95")
Cruce MAC ANIMAL - VRBLS SOCIO_DEM.
No Si p test
n 542 392
Sexo = Masculino (%) 138 (25.5) 121 (30.9) 0.081
Nocup (%) 0.021
Cesante 34 ( 6.3) 46 (11.7)
Empleado/Independiente 195 (36.0) 121 (30.9)
Estudiante 6 ( 1.1) 5 ( 1.3)
Hogar/Pensionado 307 (56.6) 220 (56.1)
Nrel (%) 0.419
Católica 401 (74.0) 298 (76.0)
Cristiana 97 (17.9) 71 (18.1)
Otra 44 ( 8.1) 23 ( 5.9)
Edadcat (%) 0.188
< 50 años 157 (29.0) 97 (24.7)
50 - 64 años 213 (39.3) 176 (44.9)
>=65 172 (31.7) 119 (30.4)
EstadoCancer = Metastasis (%) 133 (24.5) 114 (29.1) 0.139
Tipotumor = tumor solido (%) 533 (98.3) 377 (96.2) 0.064
kable(table7, format = "html", caption = "Cruce MAC PLANTAS - VRBLS SOCIO_DEM.") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), 
                full_width = F, 
                position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "#8B7E66") %>%
  column_spec(2, border_left = T, background = "#FFDAB9")
Cruce MAC PLANTAS - VRBLS SOCIO_DEM.
No Si p test
n 8 1212
Sexo = Masculino (%) 1 ( 12.5) 355 (29.3) 0.515
Nocup (%) 0.967
Cesante 1 ( 12.5) 114 ( 9.4)
Empleado/Independiente 3 ( 37.5) 400 (33.0)
Estudiante 0 ( 0.0) 11 ( 0.9)
Hogar/Pensionado 4 ( 50.0) 687 (56.7)
Nrel (%) 0.693
Católica 5 ( 62.5) 907 (74.8)
Cristiana 2 ( 25.0) 223 (18.4)
Otra 1 ( 12.5) 82 ( 6.8)
Edadcat (%) 0.827
< 50 años 2 ( 25.0) 311 (25.7)
50 - 64 años 4 ( 50.0) 488 (40.3)
>=65 2 ( 25.0) 413 (34.1)
EstadoCancer = Metastasis (%) 3 ( 37.5) 336 (27.7) 0.826
Tipotumor = tumor solido (%) 8 (100.0) 1175 (96.9) 1.000
kable(table8, format = "html", caption = "Cruce MAC NUTRICIONAL - VRBLS SOCIO_DEM.") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), 
                full_width = F, 
                position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "#B03060") %>%
  column_spec(2, border_left = T, background = "#FFDAB9")
Cruce MAC NUTRICIONAL - VRBLS SOCIO_DEM.
No Si p test
n 516 948
Sexo = Masculino (%) 166 (32.2) 270 (28.5) 0.157
Nocup (%) 0.001
Cesante 52 (10.1) 87 ( 9.2)
Empleado/Independiente 133 (25.8) 345 (36.4)
Estudiante 6 ( 1.2) 10 ( 1.1)
Hogar/Pensionado 325 (63.0) 506 (53.4)
Nrel (%) 0.434
Católica 401 (77.7) 708 (74.7)
Cristiana 82 (15.9) 171 (18.0)
Otra 33 ( 6.4) 69 ( 7.3)
Edadcat (%) 0.959
< 50 años 125 (24.2) 236 (24.9)
50 - 64 años 211 (40.9) 383 (40.4)
>=65 180 (34.9) 329 (34.7)
EstadoCancer = Metastasis (%) 163 (31.6) 262 (27.6) 0.126
Tipotumor = tumor solido (%) 501 (97.1) 919 (96.9) 0.998
kable(table9, format = "html", caption = "Cruce MAC WHOLE  - VRBLS SOCIO_DEM.") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), 
                full_width = F, 
                position = "center") %>%
  column_spec(1, bold = T, color = "white", background = "purple") %>%
  column_spec(2, border_left = T, background = "#BA55D3")
Cruce MAC WHOLE - VRBLS SOCIO_DEM.
No Si p test
n 1070 395
Sexo = Masculino (%) 328 (30.7) 109 (27.6) 0.284
Nocup (%) 0.005
Cesante 109 (10.2) 30 ( 7.6)
Empleado/Independiente 323 (30.2) 155 (39.2)
Estudiante 10 ( 0.9) 6 ( 1.5)
Hogar/Pensionado 628 (58.7) 204 (51.6)
Nrel (%) <0.001
Católica 829 (77.5) 281 (71.1)
Cristiana 185 (17.3) 68 (17.2)
Otra 56 ( 5.2) 46 (11.6)
Edadcat (%) 0.882
< 50 años 260 (24.3) 101 (25.6)
50 - 64 años 436 (40.7) 158 (40.0)
>=65 374 (35.0) 136 (34.4)
EstadoCancer = Metastasis (%) 306 (28.6) 119 (30.1) 0.612
Tipotumor = tumor solido (%) 1048 (97.9) 373 (94.4) 0.001