#  Important packages to load in
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(gtsummary)
## #Uighur
library(survival)
library(labelled)
library(tidyverse)
## ── Attaching packages ────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3     ✓ purrr   0.3.4
## ✓ tibble  3.0.3     ✓ stringr 1.4.0
## ✓ tidyr   1.1.1     ✓ forcats 0.5.0
## ✓ readr   1.3.1
## ── Conflicts ───────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(broom)
library(ggplot2)
library(survminer)
## Loading required package: ggpubr
###Intention to Treat MIS vs Open

## Importing data in to Rstudio below

NCDBOriginalData <- read.csv ("Mohamed_NCDB1.csv", header = TRUE, sep = "," )
## Subsetting distal pancreatectomies 
NCDBDistalPancreatectomy <- 
  subset(NCDBOriginalData, RX_SUMM_SURG_PRIM_SITE.2.2 == "Partial pancreatectomy, distal")
### Recoding MIS vs MIS converted to open
NCDBDistalPancreatectomy$RX_HOSP_SURG_APPR_2010[NCDBDistalPancreatectomy$RX_HOSP_SURG_APPR_2010 =="Open or approach unspecified"] <- "Open"
NCDBDistalPancreatectomy$RX_HOSP_SURG_APPR_2010[NCDBDistalPancreatectomy$RX_HOSP_SURG_APPR_2010 =="Laparoscopic"] <- "MIS"
NCDBDistalPancreatectomy$RX_HOSP_SURG_APPR_2010[NCDBDistalPancreatectomy$RX_HOSP_SURG_APPR_2010 =="Laparoscopic converted to open"] <- "MIS Converted to open"
NCDBDistalPancreatectomy$RX_HOSP_SURG_APPR_2010[NCDBDistalPancreatectomy$RX_HOSP_SURG_APPR_2010 =="Robotic assisted"] <- "MIS"
##Recoding Data within Columns Facility Location

NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="New England"] <- "NorthEast"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="New England"] <- "NorthEast"

NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="Middle Atlantic"] <- "NorthEast"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="New England"] <- "NorthEast"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="New England"] <- "NorthEast"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="East North Central"] <- "Midwest"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="East South Central"] <- "South"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="Mountain"] <- "West"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="South Atlantic"] <- "South"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="West South Central"] <- "South"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="West North Central"] <- "Midwest"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD =="Pacific"] <- "West"
NCDBDistalPancreatectomy$FACILITY_LOCATION_CD[NCDBDistalPancreatectomy$FACILITY_LOCATION_CD ==""] <- NA
###Recoding Data within income
NCDBDistalPancreatectomy$MED_INC_QUAR_12[NCDBDistalPancreatectomy$MED_INC_QUAR_12 ==""] <- NA

###recoding data within no_hsd_quar_12 
NCDBDistalPancreatectomy$NO_HSD_QUAR_12[NCDBDistalPancreatectomy$NO_HSD_QUAR_12 ==""] <- NA
##Recoding Data within Columns Population Density
NCDBDistalPancreatectomy$UR_CD_13[NCDBDistalPancreatectomy$UR_CD_13 =="Urban population of 2,500 to 19,999, adjacent to a metro area"] <- "Urban"
NCDBDistalPancreatectomy$UR_CD_13[NCDBDistalPancreatectomy$UR_CD_13 =="Counties in metro areas of 250,000 to 1 million population"] <- "Metro"
NCDBDistalPancreatectomy$UR_CD_13[NCDBDistalPancreatectomy$UR_CD_13 =="Counties in metro areas of 1 million population or more"] <- "Metro"
NCDBDistalPancreatectomy$UR_CD_13[NCDBDistalPancreatectomy$UR_CD_13 =="Completely rural or less than 2,500 urban population, not adjacent to a metro area"] <- "Rural"
NCDBDistalPancreatectomy$UR_CD_13[NCDBDistalPancreatectomy$UR_CD_13 =="Counties in metro areas of fewer than 250,000 population"] <- "Metro"
NCDBDistalPancreatectomy$UR_CD_13[NCDBDistalPancreatectomy$UR_CD_13 =="Urban population of 2,500 to 19,999, not adjacent to a metro area"] <- "Urban"
NCDBDistalPancreatectomy$UR_CD_13[NCDBDistalPancreatectomy$UR_CD_13 =="Completely rural or less than 2,500 urban population, adjacent to a metro area"] <- "Rural"
NCDBDistalPancreatectomy$UR_CD_13[NCDBDistalPancreatectomy$UR_CD_13 =="Urban population of 20,000 or more not adjacent to a metro area"] <- "Urban"
NCDBDistalPancreatectomy$UR_CD_13[NCDBDistalPancreatectomy$UR_CD_13 =="Completely rural or less than 2,500 urban population, not adjacent to a metro area"] <- "Urban"
NCDBDistalPancreatectomy$UR_CD_13[NCDBDistalPancreatectomy$UR_CD_13 ==""] <- NA
## recoding data within columns vital status
NCDBDistalPancreatectomy$PUF_VITAL_STATUS[NCDBDistalPancreatectomy$PUF_VITAL_STATUS ==""] <- NA
##Recoding Analytical Stages removing Stage IV patients

NCDBDistalPancreatectomy$ANALYTIC_STAGE_GROUP[NCDBDistalPancreatectomy$ANALYTIC_STAGE_GROUP == "AJCC Stage Group unknown"] <- NA
NCDBDistalPancreatectomy$ANALYTIC_STAGE_GROUP[NCDBDistalPancreatectomy$ANALYTIC_STAGE_GROUP == "AJCC Staging not applicable"] <- NA
NCDBDistalPancreatectomy$ANALYTIC_STAGE_GROUP[NCDBDistalPancreatectomy$ANALYTIC_STAGE_GROUP == "Unknown"] <- NA
NCDBDistalPancreatectomy$ANALYTIC_STAGE_GROUP[NCDBDistalPancreatectomy$ANALYTIC_STAGE_GROUP == "Stage IV"] <- NA
##Recoding Insurance removing Unknown patients
NCDBDistalPancreatectomy$INSURANCE_STATUS.2[NCDBDistalPancreatectomy$INSURANCE_STATUS.2 == "Unknown"] <- NA
### Recoding data in Tumor Grade Column
NCDBDistalPancreatectomy$GRADE[NCDBDistalPancreatectomy$GRADE =="Cell type not determined, not stated or not applicable, unknown primaries, high grade dysplasia"] <- NA
NCDBDistalPancreatectomy$GRADE[NCDBDistalPancreatectomy$GRADE =="Unknown"] <- NA
NCDBDistalPancreatectomy$GRADE[NCDBDistalPancreatectomy$GRADE =="Undifferentiated, anaplastic"] <- "Undifferentiated"
NCDBDistalPancreatectomy$GRADE[NCDBDistalPancreatectomy$GRADE =="Moderately differentiated, moderately well differentiated, intermediate differentiation"] <- "Moderately differentiated"
NCDBDistalPancreatectomy$GRADE[NCDBDistalPancreatectomy$GRADE =="Well differentiated, differentiated, NOS"] <- "Well differentiated"
###recode the surgical approach and make MIS converted to Open the same as MIS just before subsetting MIS and Open into new dataframe

NCDBDistalPancreatectomy$RX_HOSP_SURG_APPR_2010[NCDBDistalPancreatectomy$RX_HOSP_SURG_APPR_2010 =="MIS Converted to open"] <- "MIS"
###Subsetting MIS vs Conversion to MIS vs Open into one Dataframe

ITTMISvsOpenNCDB <- 
  subset(NCDBDistalPancreatectomy, RX_HOSP_SURG_APPR_2010 == "MIS" | RX_HOSP_SURG_APPR_2010 == "Mis Converted to open" | RX_HOSP_SURG_APPR_2010 == "Open")
##Subsetting MIS vs Conversion to MIS

MISvsConversionNCDB <- 
  subset(NCDBDistalPancreatectomy, RX_HOSP_SURG_APPR_2010 == "MIS" | RX_HOSP_SURG_APPR_2010 == "MIS Converted to open")
#### Subsetting cleaned data from one dataframe to a new dataframe
MISvsConversionvsOpenNCDBDemoTable <-
  ITTMISvsOpenNCDB %>%
  select(RX_HOSP_SURG_APPR_2010, AGE, SEX, RACE.2, INSURANCE_STATUS.2, FACILITY_LOCATION_CD, MED_INC_QUAR_12, NO_HSD_QUAR_12, UR_CD_13, CDCC_TOTAL_BEST, ANALYTIC_STAGE_GROUP, GRADE, REGIONAL_NODES_POSITIVE, RX_SUMM_RADIATION, RX_SUMM_CHEMO, HISTOLOGY.2.2, DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS)
### Recoding data in Radiationtherapy
MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION =="Beam radiation"] <- "Yes"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION =="None"] <- "None"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION =="Radiation therapy, NOS"] <- "Yes"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION =="Radioactive implants"] <- NA

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION =="Radioisotopes"] <- NA

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_RADIATION =="Unknown"] <- NA
### Recoding data in Chemotherapy
MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO =="Chemotherapy administered, type and number of agents not documented"] <- "Yes"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO =="Multiagent chemotherapy"] <- "Yes"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO =="Single-agent chemotherapy"] <- "Yes"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO =="None"] <- "No"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO =="Chemotherapy not administered, was recommended, not administered Reason unknown"] <- "No"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO =="Chemotherapy not administered, recommended, but refused by patient, patient's family member or guardian"] <- "No"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO =="Chemotherapy not administered, patient died prior to planned or recommended therapy"] <- "No"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO =="Chemotherapy not recommended/administered, contraindicated due to patient risk factors"] <- "No"

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO =="Chemotherapy recommended, unknown if administered"] <- NA

MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO[MISvsConversionvsOpenNCDBDemoTable$RX_SUMM_CHEMO =="Unknown if recommended or administered"] <- NA
### Recoding data Lymph Nodes

MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE <- as.character(MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE)
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="1"] <- "<5"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="2"] <- "<5"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="3"] <- "<5"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="4"] <- "<5"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="5"] <- "<5"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="6"] <- "5-10"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="7"] <- "5-10"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="8"] <- "5-10"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="9"] <- "5-10"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="10"] <- "5-10"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="11"] <- "11-15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="12"] <- "11-15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="13"] <- "11-15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="14"] <- "11-15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="15"] <- "11-15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="16"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="17"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="18"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="19"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="20"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="21"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="22"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="23"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="24"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="25"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="26"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="27"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="28"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="29"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="30"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="31"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="32"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="33"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="34"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="35"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="36"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="37"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="38"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="39"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="40"] <- ">15"
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="64"] <- ">15"



MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="All nodes examined are negative"] <- NA
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="No nodes were examined"] <- NA
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="Positive aspiration of lymph node(s) was performed"] <- NA
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="Positive nodes are documented, but the number is unspecified"] <- NA
MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE[MISvsConversionvsOpenNCDBDemoTable$REGIONAL_NODES_POSITIVE =="Unknown whether nodes are positive, not applicable, not stated in patient record"] <- NA
###Labeling Columns for MISvsCOnversionVsopenNCDBDemotable
var_label(MISvsConversionvsOpenNCDBDemoTable$AGE) <- "Age"
var_label(MISvsConversionvsOpenNCDBDemoTable$SEX) <- "Sex"
var_label(MISvsConversionvsOpenNCDBDemoTable$RACE.2) <- "Race"
var_label(MISvsConversionvsOpenNCDBDemoTable$INSURANCE_STATUS.2) <- "Insurance Status"
var_label(MISvsConversionvsOpenNCDBDemoTable$FACILITY_LOCATION_CD) <- "Region"
var_label(MISvsConversionvsOpenNCDBDemoTable$MED_INC_QUAR_12) <- "Income"
var_label(MISvsConversionvsOpenNCDBDemoTable$NO_HSD_QUAR_12) <- "No High School Degree"
var_label(MISvsConversionvsOpenNCDBDemoTable$CDCC_TOTAL_BEST) <- "Charlson-Deyo Disability Score"
var_label(MISvsConversionvsOpenNCDBDemoTable$UR_CD_13) <- "Population"
var_label(MISvsConversionvsOpenNCDBDemoTable$RX_HOSP_SURG_APPR_2010) <- "Surgery"
var_label(MISvsConversionvsOpenNCDBDemoTable$ANALYTIC_STAGE_GROUP) <- "Staging"
var_label(MISvsConversionvsOpenNCDBDemoTable$GRADE) <- "Tumor Grade"
var_label(MISvsConversionvsOpenNCDBDemoTable$DX_LASTCONTACT_DEATH_MONTHS) <- "Median Survival"
var_label(MISvsConversionvsOpenNCDBDemoTable$PUF_VITAL_STATUS) <- "Vital Status"
MISvsOpenCarcinoma <- 
  subset(MISvsConversionvsOpenNCDBDemoTable, HISTOLOGY.2.2 == "Carcinoma")

MISvsOpenCarcinoma\(ANALYTIC_STAGE_GROUP[MISvsOpenCarcinoma\)ANALYTIC_STAGE_GROUP ==“Stage 0”] <- NA

#Final Step to create demographic table
MISvsOpenCarcinoma %>%
  tbl_summary(
    by = RX_HOSP_SURG_APPR_2010,
    digits = all_continuous() ~ 2,) %>%
  add_p(pvalue_fun = ~style_pvalue(.x, digits = 2))%>%
  bold_p() %>%
  add_overall() %>%
  modify_header(label ~ "**Variables**") %>%
  modify_spanning_header(c("stat_0", "stat_1") ~ "**NCDB Long Term Outcomes**") %>%
  bold_labels() 
## There was an error in 'add_p()' for variable 'HISTOLOGY.2.2', p-value omitted:
## Error in stats::chisq.test(data[[variable]], as.factor(data[[by]])): 'x' and 'y' must have at least 2 levels
Variables NCDB Long Term Outcomes Open, N = 3,4981 p-value2
Overall, N = 5,4441 MIS, N = 1,9461
AGE 67.00 (60.00, 75.00) 68.00 (60.00, 76.00) 67.00 (59.00, 75.00) <0.001
SEX 0.94
Female 2,870 (53%) 1,024 (53%) 1,846 (53%)
Male 2,574 (47%) 922 (47%) 1,652 (47%)
RACE.2 0.35
Black 636 (12%) 211 (11%) 425 (12%)
Other 261 (4.8%) 93 (4.8%) 168 (4.8%)
White 4,547 (84%) 1,642 (84%) 2,905 (83%)
INSURANCE_STATUS.2 0.029
Medicaid 268 (5.0%) 89 (4.6%) 179 (5.2%)
Medicare 3,055 (57%) 1,137 (59%) 1,918 (55%)
Not Insured 115 (2.1%) 31 (1.6%) 84 (2.4%)
Private Insurance/Managed Care/Goverment 1,950 (36%) 671 (35%) 1,279 (37%)
Unknown 56 18 38
FACILITY_LOCATION_CD <0.001
Midwest 1,409 (26%) 482 (25%) 927 (27%)
NorthEast 1,326 (25%) 542 (28%) 784 (23%)
South 1,971 (37%) 672 (35%) 1,299 (38%)
West 659 (12%) 226 (12%) 433 (13%)
Unknown 79 24 55
MED_INC_QUAR_12 0.41
< $38,000 853 (16%) 293 (15%) 560 (16%)
>=$63,000 1,981 (36%) 731 (38%) 1,250 (36%)
$38,000-$47,999 1,185 (22%) 408 (21%) 777 (22%)
$48,000-$62,999 1,417 (26%) 512 (26%) 905 (26%)
Unknown 8 2 6
NO_HSD_QUAR_12 0.008
<7.0% 1,549 (28%) 573 (29%) 976 (28%)
>=21.0% 766 (14%) 270 (14%) 496 (14%)
13.0-20.9% 1,364 (25%) 438 (23%) 926 (26%)
7.0-12.9% 1,760 (32%) 663 (34%) 1,097 (31%)
Unknown 5 2 3
UR_CD_13 0.92
Metro 4,529 (85%) 1,624 (86%) 2,905 (85%)
Rural 92 (1.7%) 31 (1.6%) 61 (1.8%)
Urban 467 (8.8%) 162 (8.6%) 305 (8.9%)
Urban population of 20,000 or more adjacent to a metro area 210 (4.0%) 73 (3.9%) 137 (4.0%)
Unknown 146 56 90
CDCC_TOTAL_BEST 0.37
>=3 220 (4.0%) 84 (4.3%) 136 (3.9%)
0 3,253 (60%) 1,133 (58%) 2,120 (61%)
1 1,570 (29%) 579 (30%) 991 (28%)
2 401 (7.4%) 150 (7.7%) 251 (7.2%)
ANALYTIC_STAGE_GROUP 0.001
Stage 0 148 (2.9%) 56 (3.0%) 92 (2.9%)
Stage I 1,064 (21%) 373 (20%) 691 (21%)
Stage II 3,691 (73%) 1,379 (75%) 2,312 (72%)
Stage III 161 (3.2%) 36 (2.0%) 125 (3.9%)
Unknown 380 102 278
GRADE 0.97
Moderately differentiated 2,577 (54%) 935 (55%) 1,642 (54%)
Poorly differentiated 1,460 (31%) 529 (31%) 931 (31%)
Undifferentiated 82 (1.7%) 30 (1.8%) 52 (1.7%)
Well differentiated 612 (13%) 216 (13%) 396 (13%)
Unknown 713 236 477
REGIONAL_NODES_POSITIVE 0.87
<5 2,250 (88%) 824 (88%) 1,426 (87%)
>15 12 (0.5%) 3 (0.3%) 9 (0.6%)
11-15 49 (1.9%) 17 (1.8%) 32 (2.0%)
5-10 256 (10.0%) 91 (9.7%) 165 (10%)
Unknown 2,877 1,011 1,866
RX_SUMM_RADIATION 0.001
None 4,063 (75%) 1,499 (78%) 2,564 (74%)
Yes 1,343 (25%) 429 (22%) 914 (26%)
Unknown 38 18 20
RX_SUMM_CHEMO 3,550 (69%) 1,268 (69%) 2,282 (68%) 0.80
Unknown 266 103 163
HISTOLOGY.2.2
Carcinoma 5,444 (100%) 1,946 (100%) 3,498 (100%)
DX_LASTCONTACT_DEATH_MONTHS 20.37 (10.81, 35.22) 21.13 (11.76, 34.27) 19.73 (10.28, 35.82) 0.051
Unknown 863 387 476
PUF_VITAL_STATUS <0.001
Alive 1,689 (37%) 657 (42%) 1,032 (34%)
Dead 2,892 (63%) 902 (58%) 1,990 (66%)
Unknown 863 387 476

1 Statistics presented: Median (IQR); n (%)

2 Statistical tests performed: Wilcoxon rank-sum test; chi-square test of independence; Fisher's exact test

###No high school degree blanks to NA's
MISvsOpenCarcinoma$NO_HSD_QUAR_12[MISvsOpenCarcinoma$NO_HSD_QUAR_12 ==""] <- NA
#####Survival Analysis Ensure that vital status is labeled as 1= Alive and 2=Death
MISvsOpenCarcinoma$PUF_VITAL_STATUS[MISvsOpenCarcinoma$PUF_VITAL_STATUS == "Dead"] <- 2

MISvsOpenCarcinoma$PUF_VITAL_STATUS[MISvsOpenCarcinoma$PUF_VITAL_STATUS == "Alive"] <- 1
###pufvitalstatus should be numeric
MISvsOpenCarcinoma$PUF_VITAL_STATUS <- as.numeric(MISvsOpenCarcinoma$PUF_VITAL_STATUS)


###RX_HOSP_SURG_APPR_2010 should be numeric
MISvsOpenCarcinoma$DX_LASTCONTACT_DEATH_MONTHS <- as.numeric(MISvsOpenCarcinoma$DX_LASTCONTACT_DEATH_MONTHS)
MISvsOpenCarcinoma$ANALYTIC_STAGE_GROUP <- as.factor(MISvsOpenCarcinoma$ANALYTIC_STAGE_GROUP)



MISvsOpenCarcinoma$ANALYTIC_STAGE_GROUP = relevel(MISvsOpenCarcinoma$ANALYTIC_STAGE_GROUP, ref="Stage 0")
### Univariant Survival Neoadj
UVSurv <-
  MISvsOpenCarcinoma %>%
  select(RX_HOSP_SURG_APPR_2010, RACE.2, INSURANCE_STATUS.2, FACILITY_LOCATION_CD, MED_INC_QUAR_12, NO_HSD_QUAR_12, ANALYTIC_STAGE_GROUP, GRADE, RX_SUMM_CHEMO, RX_SUMM_RADIATION, DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) %>%
  tbl_uvregression(
    method = coxph,
    y = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS),
    exponentiate = TRUE) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()

###Multivariant survival Neoadj
MVSurv <-
  coxph(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ RX_HOSP_SURG_APPR_2010 + RACE.2 + INSURANCE_STATUS.2 + FACILITY_LOCATION_CD + MED_INC_QUAR_12 + NO_HSD_QUAR_12 + ANALYTIC_STAGE_GROUP + GRADE + RX_SUMM_CHEMO + RX_SUMM_RADIATION,
        data = MISvsOpenCarcinoma
  ) %>%
  tbl_regression(exponentiate = T
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
###Merged Neo Univariant and Multivariant
tbl_merge(
  list(UVSurv, MVSurv),
  tab_spanner = c("**Univariable**", "**Multivariable**")
) %>%
  bold_labels() %>%
  italicize_levels()
Characteristic Univariable Multivariable
N HR1 95% CI1 p-value HR1 95% CI1 p-value
RX_HOSP_SURG_APPR_2010 4,581
MIS
Open 1.16 1.07, 1.26 <0.001 1.19 1.08, 1.30 <0.001
RACE.2 4,581
Black
Other 0.68 0.55, 0.84 <0.001 0.82 0.63, 1.07 0.14
White 0.97 0.86, 1.08 0.5 0.98 0.86, 1.11 0.7
INSURANCE_STATUS.2 4,535
Medicaid
Medicare 1.07 0.90, 1.27 0.5 1.01 0.82, 1.24 >0.9
Not Insured 0.95 0.70, 1.28 0.7 0.95 0.67, 1.34 0.8
Private Insurance/Managed Care/Goverment 0.76 0.64, 0.91 0.003 0.78 0.63, 0.96 0.019
FACILITY_LOCATION_CD 4,514
Midwest
NorthEast 0.82 0.74, 0.91 <0.001 0.86 0.76, 0.97 0.011
South 1.06 0.97, 1.17 0.2 1.08 0.97, 1.20 0.2
West 0.92 0.81, 1.05 0.2 1.03 0.89, 1.19 0.7
MED_INC_QUAR_12 4,574
< $38,000
>=$63,000 0.76 0.69, 0.85 <0.001 0.75 0.64, 0.89 <0.001
$38,000-$47,999 0.93 0.82, 1.04 0.2 0.90 0.78, 1.04 0.2
$48,000-$62,999 0.84 0.74, 0.94 0.002 0.84 0.72, 0.97 0.019
NO_HSD_QUAR_12 4,576
<7.0%
>=21.0% 1.26 1.12, 1.41 <0.001 0.97 0.81, 1.16 0.8
13.0-20.9% 1.17 1.06, 1.30 0.002 0.98 0.85, 1.13 0.8
7.0-12.9% 1.12 1.02, 1.23 0.023 1.08 0.96, 1.22 0.2
ANALYTIC_STAGE_GROUP 4,256
Stage 0
Stage I 4.04 2.41, 6.76 <0.001 5.09 1.27, 20.5 0.022
Stage II 8.32 5.01, 13.8 <0.001 10.3 2.55, 41.2 0.001
Stage III 10.2 5.92, 17.5 <0.001 14.2 3.48, 58.1 <0.001
GRADE 4,006
Moderately differentiated
Poorly differentiated 1.36 1.25, 1.48 <0.001 1.37 1.25, 1.50 <0.001
Undifferentiated 1.31 0.97, 1.77 0.082 1.16 0.81, 1.67 0.4
Well differentiated 0.59 0.51, 0.67 <0.001 0.65 0.56, 0.75 <0.001
RX_SUMM_CHEMO 4,351
No
Yes 0.91 0.84, 0.99 0.020 0.67 0.61, 0.74 <0.001
RX_SUMM_RADIATION 4,546
None
Yes 0.93 0.85, 1.01 0.076 1.01 0.91, 1.11 >0.9

1 HR = Hazard Ratio, CI = Confidence Interval

survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ RX_HOSP_SURG_APPR_2010, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     RX_HOSP_SURG_APPR_2010, data = MISvsOpenCarcinoma)
## 
##    863 observations deleted due to missingness 
##                                n events median 0.95LCL 0.95UCL
## RX_HOSP_SURG_APPR_2010=MIS  1559    902   27.6    25.7    29.7
## RX_HOSP_SURG_APPR_2010=Open 3022   1990   23.2    22.3    24.6
survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ RACE.2, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     RACE.2, data = MISvsOpenCarcinoma)
## 
##    863 observations deleted due to missingness 
##                 n events median 0.95LCL 0.95UCL
## RACE.2=Black  553    357   23.3    21.1    28.2
## RACE.2=Other  222    111   34.2    28.2    45.3
## RACE.2=White 3806   2424   24.5    23.4    25.5
survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ INSURANCE_STATUS.2, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     INSURANCE_STATUS.2, data = MISvsOpenCarcinoma)
## 
##    909 observations deleted due to missingness 
##                                                                n events median
## INSURANCE_STATUS.2=Medicaid                                  221    140   23.8
## INSURANCE_STATUS.2=Medicare                                 2553   1728   22.1
## INSURANCE_STATUS.2=Not Insured                                97     61   23.4
## INSURANCE_STATUS.2=Private Insurance/Managed Care/Goverment 1664    938   30.0
##                                                             0.95LCL 0.95UCL
## INSURANCE_STATUS.2=Medicaid                                    20.1    28.0
## INSURANCE_STATUS.2=Medicare                                    21.1    23.3
## INSURANCE_STATUS.2=Not Insured                                 19.4    35.3
## INSURANCE_STATUS.2=Private Insurance/Managed Care/Goverment    27.9    32.8
survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ FACILITY_LOCATION_CD, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     FACILITY_LOCATION_CD, data = MISvsOpenCarcinoma)
## 
##    930 observations deleted due to missingness 
##                                   n events median 0.95LCL 0.95UCL
## FACILITY_LOCATION_CD=Midwest   1201    788   23.3    22.0    25.0
## FACILITY_LOCATION_CD=NorthEast 1128    674   29.4    26.7    33.0
## FACILITY_LOCATION_CD=South     1633   1074   21.9    20.7    23.5
## FACILITY_LOCATION_CD=West       552    342   25.2    23.2    29.0
survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ MED_INC_QUAR_12, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     MED_INC_QUAR_12, data = MISvsOpenCarcinoma)
## 
##    870 observations deleted due to missingness 
##                                    n events median 0.95LCL 0.95UCL
## MED_INC_QUAR_12=< $38,000        720    484   21.6    19.6    23.5
## MED_INC_QUAR_12=>=$63,000       1677   1004   28.1    25.9    30.1
## MED_INC_QUAR_12=$38,000-$47,999 1003    663   22.0    20.6    25.1
## MED_INC_QUAR_12=$48,000-$62,999 1174    737   24.6    23.1    27.7
survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ NO_HSD_QUAR_12, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     NO_HSD_QUAR_12, data = MISvsOpenCarcinoma)
## 
##    868 observations deleted due to missingness 
##                              n events median 0.95LCL 0.95UCL
## NO_HSD_QUAR_12=<7.0%      1304    781   28.4    26.1    31.0
## NO_HSD_QUAR_12=>=21.0%     659    430   22.8    20.8    24.9
## NO_HSD_QUAR_12=13.0-20.9% 1146    744   23.1    20.8    25.7
## NO_HSD_QUAR_12=7.0-12.9%  1467    934   24.1    22.8    25.7
survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ ANALYTIC_STAGE_GROUP, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     ANALYTIC_STAGE_GROUP, data = MISvsOpenCarcinoma)
## 
##    1188 observations deleted due to missingness 
##                                   n events median 0.95LCL 0.95UCL
## ANALYTIC_STAGE_GROUP=Stage 0    118     15     NA      NA      NA
## ANALYTIC_STAGE_GROUP=Stage I    921    414   48.5    42.2    59.0
## ANALYTIC_STAGE_GROUP=Stage II  3083   2113   22.4    21.6    23.3
## ANALYTIC_STAGE_GROUP=Stage III  134    100   19.8    18.2    24.5
survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ GRADE, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     GRADE, data = MISvsOpenCarcinoma)
## 
##    1438 observations deleted due to missingness 
##                                    n events median 0.95LCL 0.95UCL
## GRADE=Moderately differentiated 2176   1414   25.2    23.9    26.9
## GRADE=Poorly differentiated     1244    935   18.1    16.7    19.1
## GRADE=Undifferentiated            68     43   14.4    12.0    26.0
## GRADE=Well differentiated        518    247   47.6    43.4    55.5
survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ REGIONAL_NODES_POSITIVE, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     REGIONAL_NODES_POSITIVE, data = MISvsOpenCarcinoma)
## 
##    3293 observations deleted due to missingness 
##                                  n events median 0.95LCL 0.95UCL
## REGIONAL_NODES_POSITIVE=<5    1896   1385  20.40   19.32    21.4
## REGIONAL_NODES_POSITIVE=>15     11     10   9.66    4.86      NA
## REGIONAL_NODES_POSITIVE=11-15   33     22  18.63    9.79      NA
## REGIONAL_NODES_POSITIVE=5-10   211    174  16.59   15.01    20.2
survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ RX_SUMM_CHEMO, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     RX_SUMM_CHEMO, data = MISvsOpenCarcinoma)
## 
##    1093 observations deleted due to missingness 
##                      n events median 0.95LCL 0.95UCL
## RX_SUMM_CHEMO=No  1390    859   21.0    19.2    23.8
## RX_SUMM_CHEMO=Yes 2961   1884   25.7    24.7    26.9
survfit(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ RX_SUMM_RADIATION, data = MISvsOpenCarcinoma)
## Call: survfit(formula = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ 
##     RX_SUMM_RADIATION, data = MISvsOpenCarcinoma)
## 
##    898 observations deleted due to missingness 
##                           n events median 0.95LCL 0.95UCL
## RX_SUMM_RADIATION=None 3371   2096   23.7    22.7    25.1
## RX_SUMM_RADIATION=Yes  1175    772   26.4    25.1    28.9
MISvsOpenCarcinomaStage1<-
  subset(MISvsOpenCarcinoma,  ANALYTIC_STAGE_GROUP == "Stage I")

MISvsOpenCarcinomaStage2<-
  subset(MISvsOpenCarcinoma,  ANALYTIC_STAGE_GROUP == "Stage II")

MISvsOpenCarcinomaStage3<-
  subset(MISvsOpenCarcinoma,  ANALYTIC_STAGE_GROUP == "Stage III")
### Univariant Survival Neoadj Stage I
UVSurvstage1 <-
  MISvsOpenCarcinomaStage1 %>%
  select(RX_HOSP_SURG_APPR_2010, RACE.2, INSURANCE_STATUS.2, FACILITY_LOCATION_CD, MED_INC_QUAR_12, NO_HSD_QUAR_12, ANALYTIC_STAGE_GROUP, GRADE, RX_SUMM_CHEMO, RX_SUMM_RADIATION, DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) %>%
  tbl_uvregression(
    method = coxph,
    y = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS),
    exponentiate = TRUE) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()

###Multivariant survival Neoadj
MVSurvStage1 <-
  coxph(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ RX_HOSP_SURG_APPR_2010 + RACE.2 + INSURANCE_STATUS.2 + FACILITY_LOCATION_CD + MED_INC_QUAR_12 + NO_HSD_QUAR_12 + GRADE + RX_SUMM_CHEMO + RX_SUMM_RADIATION,
        data = MISvsOpenCarcinomaStage1
  ) %>%
  tbl_regression(exponentiate = T
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
###Merged Neo Univariant and Multivariant
tbl_merge(
  list(UVSurvstage1, MVSurvStage1),
  tab_spanner = c("**Univariable**", "**Multivariable**")
) %>%
  bold_labels() %>%
  italicize_levels()
Characteristic Univariable Multivariable
N HR1 95% CI1 p-value HR1 95% CI1 p-value
RX_HOSP_SURG_APPR_2010 921
MIS
Open 1.22 0.99, 1.51 0.066 1.30 1.02, 1.65 0.035
RACE.2 921
Black
Other 0.47 0.25, 0.87 0.016 0.56 0.28, 1.11 0.10
White 1.11 0.82, 1.51 0.5 1.17 0.83, 1.67 0.4
INSURANCE_STATUS.2 911
Medicaid
Medicare 1.47 0.91, 2.37 0.11 1.26 0.73, 2.18 0.4
Not Insured 1.10 0.49, 2.44 0.8 0.93 0.35, 2.45 0.9
Private Insurance/Managed Care/Goverment 0.68 0.41, 1.12 0.13 0.60 0.34, 1.06 0.076
FACILITY_LOCATION_CD 889
Midwest
NorthEast 0.93 0.70, 1.24 0.6 1.04 0.75, 1.44 0.8
South 1.15 0.89, 1.47 0.3 1.11 0.83, 1.47 0.5
West 1.18 0.86, 1.60 0.3 1.21 0.85, 1.72 0.3
MED_INC_QUAR_12 919
< $38,000
>=$63,000 0.76 0.57, 1.00 0.052 0.87 0.57, 1.34 0.5
$38,000-$47,999 0.95 0.69, 1.29 0.7 0.95 0.65, 1.39 0.8
$48,000-$62,999 0.94 0.70, 1.26 0.7 1.12 0.76, 1.65 0.6
NO_HSD_QUAR_12 919
<7.0%
>=21.0% 1.44 1.06, 1.95 0.019 1.18 0.76, 1.85 0.5
13.0-20.9% 1.33 1.02, 1.73 0.035 1.24 0.85, 1.79 0.3
7.0-12.9% 1.21 0.94, 1.58 0.14 1.12 0.82, 1.55 0.5
ANALYTIC_STAGE_GROUP 921
Stage I
GRADE 780
Moderately differentiated
Poorly differentiated 1.50 1.18, 1.89 <0.001 1.47 1.14, 1.89 0.003
Undifferentiated 1.82 0.90, 3.70 0.10 2.08 0.96, 4.50 0.063
Well differentiated 0.53 0.40, 0.71 <0.001 0.55 0.40, 0.76 <0.001
RX_SUMM_CHEMO 883
No
Yes 1.08 0.88, 1.32 0.5 0.83 0.65, 1.07 0.15
RX_SUMM_RADIATION 919
None
Yes 1.16 0.92, 1.45 0.2 1.26 0.95, 1.67 0.11

1 HR = Hazard Ratio, CI = Confidence Interval

### Univariant Survival Neoadj Stage II
UVSurvstage2 <-
  MISvsOpenCarcinomaStage2 %>%
  select(RX_HOSP_SURG_APPR_2010, RACE.2, INSURANCE_STATUS.2, FACILITY_LOCATION_CD, MED_INC_QUAR_12, NO_HSD_QUAR_12, GRADE, RX_SUMM_CHEMO, RX_SUMM_RADIATION, DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) %>%
  tbl_uvregression(
    method = coxph,
    y = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS),
    exponentiate = TRUE) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()

###Multivariant survival Neoadj
MVSurvStage2 <-
  coxph(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ RX_HOSP_SURG_APPR_2010 + RACE.2 + INSURANCE_STATUS.2 + FACILITY_LOCATION_CD + MED_INC_QUAR_12 + NO_HSD_QUAR_12 + GRADE + RX_SUMM_CHEMO + RX_SUMM_RADIATION,
        data = MISvsOpenCarcinomaStage2
  ) %>%
  tbl_regression(exponentiate = T
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
###Merged Neo Univariant and Multivariant
tbl_merge(
  list(UVSurvstage2, MVSurvStage2),
  tab_spanner = c("**Univariable**", "**Multivariable**")
) %>%
  bold_labels() %>%
  italicize_levels()
Characteristic Univariable Multivariable
N HR1 95% CI1 p-value HR1 95% CI1 p-value
RX_HOSP_SURG_APPR_2010 3,083
MIS
Open 1.16 1.06, 1.27 0.001 1.17 1.06, 1.29 0.002
RACE.2 3,083
Black
Other 0.76 0.59, 0.99 0.039 0.94 0.70, 1.25 0.7
White 0.99 0.87, 1.13 0.9 0.99 0.85, 1.14 0.8
INSURANCE_STATUS.2 3,052
Medicaid
Medicare 1.04 0.85, 1.29 0.7 1.02 0.81, 1.28 0.9
Not Insured 1.06 0.74, 1.52 0.7 1.02 0.70, 1.51 >0.9
Private Insurance/Managed Care/Goverment 0.83 0.67, 1.03 0.084 0.85 0.67, 1.07 0.2
FACILITY_LOCATION_CD 3,063
Midwest
NorthEast 0.80 0.71, 0.90 <0.001 0.83 0.73, 0.95 0.005
South 1.11 1.00, 1.24 0.052 1.06 0.94, 1.20 0.3
West 0.98 0.85, 1.15 0.8 0.98 0.83, 1.16 0.9
MED_INC_QUAR_12 3,081
< $38,000
>=$63,000 0.75 0.66, 0.85 <0.001 0.71 0.59, 0.86 <0.001
$38,000-$47,999 0.90 0.79, 1.03 0.14 0.86 0.73, 1.00 0.053
$48,000-$62,999 0.84 0.73, 0.96 0.009 0.76 0.64, 0.89 0.001
NO_HSD_QUAR_12 3,082
<7.0%
>=21.0% 1.21 1.05, 1.39 0.007 0.91 0.74, 1.11 0.3
13.0-20.9% 1.12 0.99, 1.26 0.064 0.93 0.79, 1.09 0.4
7.0-12.9% 1.09 0.97, 1.21 0.14 1.06 0.92, 1.21 0.4
GRADE 2,835
Moderately differentiated
Poorly differentiated 1.31 1.19, 1.44 <0.001 1.35 1.22, 1.49 <0.001
Undifferentiated 1.06 0.71, 1.59 0.8 0.96 0.62, 1.50 0.9
Well differentiated 0.73 0.62, 0.87 <0.001 0.69 0.58, 0.83 <0.001
RX_SUMM_CHEMO 2,907
No
Yes 0.63 0.57, 0.70 <0.001 0.63 0.56, 0.70 <0.001
RX_SUMM_RADIATION 3,059
None
Yes 0.82 0.75, 0.91 <0.001 0.99 0.89, 1.11 0.9

1 HR = Hazard Ratio, CI = Confidence Interval

### Univariant Survival Neoadj Stage III
UVSurvstage3 <-
  MISvsOpenCarcinomaStage3 %>%
  select(RX_HOSP_SURG_APPR_2010, RACE.2, INSURANCE_STATUS.2, FACILITY_LOCATION_CD, MED_INC_QUAR_12, NO_HSD_QUAR_12, GRADE, RX_SUMM_CHEMO, RX_SUMM_RADIATION, DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) %>%
  tbl_uvregression(
    method = coxph,
    y = Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS),
    exponentiate = TRUE) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()

###Multivariant survival Neoadj
MVSurvStage3 <-
  coxph(Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS) ~ RX_HOSP_SURG_APPR_2010 + RACE.2 + INSURANCE_STATUS.2 + FACILITY_LOCATION_CD + MED_INC_QUAR_12 + NO_HSD_QUAR_12 + GRADE + RX_SUMM_CHEMO + RX_SUMM_RADIATION,
        data = MISvsOpenCarcinomaStage3
  ) %>%
  tbl_regression(exponentiate = T
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
###Merged Neo Univariant and Multivariant
tbl_merge(
  list(UVSurvstage3, MVSurvStage3),
  tab_spanner = c("**Univariable**", "**Multivariable**")
) %>%
  bold_labels() %>%
  italicize_levels()
Characteristic Univariable Multivariable
N HR1 95% CI1 p-value HR1 95% CI1 p-value
RX_HOSP_SURG_APPR_2010 134
MIS
Open 1.05 0.64, 1.72 0.8 1.06 0.53, 2.11 0.9
RACE.2 134
Black
Other 0.47 0.14, 1.61 0.2 1.18 0.19, 7.42 0.9
White 0.47 0.28, 0.81 0.007 0.30 0.13, 0.69 0.005
INSURANCE_STATUS.2 133
Medicaid
Medicare 0.73 0.31, 1.72 0.5 0.19 0.05, 0.72 0.014
Not Insured 0.58 0.12, 2.92 0.5 0.13 0.02, 1.07 0.058
Private Insurance/Managed Care/Goverment 0.62 0.26, 1.46 0.3 0.22 0.05, 0.91 0.036
FACILITY_LOCATION_CD 134
Midwest
NorthEast 1.07 0.60, 1.92 0.8 0.95 0.38, 2.40 >0.9
South 1.16 0.68, 1.99 0.6 0.94 0.42, 2.09 0.9
West 0.70 0.35, 1.39 0.3 0.56 0.20, 1.60 0.3
MED_INC_QUAR_12 133
< $38,000
>=$63,000 1.21 0.59, 2.49 0.6 1.16 0.33, 4.11 0.8
$38,000-$47,999 1.76 0.81, 3.82 0.2 2.54 0.77, 8.34 0.13
$48,000-$62,999 1.89 0.87, 4.09 0.11 2.14 0.63, 7.24 0.2
NO_HSD_QUAR_12 133
<7.0%
>=21.0% 1.62 0.89, 2.95 0.11 0.68 0.23, 2.05 0.5
13.0-20.9% 1.32 0.74, 2.34 0.3 0.86 0.31, 2.36 0.8
7.0-12.9% 1.40 0.84, 2.33 0.2 1.66 0.81, 3.39 0.2
GRADE 99
Moderately differentiated
Poorly differentiated 1.24 0.77, 1.99 0.4 1.42 0.77, 2.62 0.3
Undifferentiated 1.47 0.35, 6.12 0.6 0.95 0.18, 5.11 >0.9
Well differentiated 0.61 0.30, 1.27 0.2 0.45 0.17, 1.16 0.10
RX_SUMM_CHEMO 129
No
Yes 0.39 0.25, 0.63 <0.001 0.43 0.19, 0.94 0.035
RX_SUMM_RADIATION 132
None
Yes 0.50 0.33, 0.74 <0.001 0.78 0.39, 1.55 0.5

1 HR = Hazard Ratio, CI = Confidence Interval

#  Important packages to load in
library(dplyr)
library(gtsummary)
library(survival)
library(labelled)
library(tidyverse)
library(broom)
library(ggplot2)
library(survminer)
NSQIPShortTermOutcomes <- read.csv ("PANFINAL.csv", header = TRUE, sep = "," )

unique(NSQIPShortTermOutcomes$PAN_MALIG_HISTOLOGIC)
##  [1] "Other type"                    "Pancreatic adenocarcinoma"    
##  [3] "Duodenal carcinoma"            "N/A"                          
##  [5] "Neuroendocrine-nonfunctioning" "Neuroendocrine-functioning"   
##  [7] "Ampullary carcinoma"           "Distal cholangiocarcinoma"    
##  [9] "IPMN-invasive"                 "Unknown"                      
## [11] "Cystadenocarcinoma"
##Creating BMI column from heigh, weight
  NSQIPShortTermOutcomes$BMI <- (NSQIPShortTermOutcomes$WEIGHT * 703) / (NSQIPShortTermOutcomes$HEIGHT * NSQIPShortTermOutcomes$HEIGHT)
NSQIPShortTermOutcomes <- 
  subset(NSQIPShortTermOutcomes, CPT == "48140" | CPT == "48145")
NSQIPShortTermOutcomes <- 
  subset(NSQIPShortTermOutcomes, PAN_MALIG_HISTOLOGIC == "Pancreatic adenocarcinoma")
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Open (planned)"] <- "Open"
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="NOTES w/ unplanned conversion to open"] <- "MIS"
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Laparoscopic"] <- "MIS"
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Laparoscopic w/ open assist"] <- "MIS Converted to Open" 
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Laparoscopic w/ unplanned conversion to open"] <- "MIS"
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Robotic"] <- "MIS"
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Robotic w/ unplanned conversion to open"] <- "MIS"
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Robotic w/ open assist"] <- "MIS Converted to Open" 
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Other"] <- NA
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Other MIS approach"] <- "MIS"
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Other MIS approach w/ open assist"] <- "MIS Converted to Open"
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Hybrid"] <- "MIS"
NSQIPShortTermOutcomes$PAN_APPROACH[NSQIPShortTermOutcomes$PAN_APPROACH =="Hybrid w/ open assist"] <- "MIS Converted to Open"
NSQIPShortTermOutcomes$PRSEPIS[NSQIPShortTermOutcomes$PRSEPIS == "SIRS"] <- "Yes"
NSQIPShortTermOutcomes$PRSEPIS[NSQIPShortTermOutcomes$PRSEPIS == "Septic Shock"] <- "Yes"
NSQIPShortTermOutcomes$PRSEPIS[NSQIPShortTermOutcomes$PRSEPIS == "Sepsis"] <- "Yes"

NSQIPShortTermOutcomes$ASACLAS[NSQIPShortTermOutcomes$ASACLAS =="None assigned"] <- "Unknown"
NSQIPShortTermOutcomes$RACE_NEW[NSQIPShortTermOutcomes$RACE_NEW == "American Indian or Alaska Native"] <- "Other"
NSQIPShortTermOutcomes$RACE_NEW[NSQIPShortTermOutcomes$RACE_NEW == "Asian"] <- "Other"
NSQIPShortTermOutcomes$RACE_NEW[NSQIPShortTermOutcomes$RACE_NEW == "Native Hawaiian or Pacific Islander"] <- "Other"
NSQIPShortTermOutcomes$RACE_NEW[NSQIPShortTermOutcomes$RACE_NEW == "Black or African American"] <- "Black"
NSQIPShortTermOutcomes$RACE_NEW[NSQIPShortTermOutcomes$RACE_NEW == "Unknown/Not Reported"] <- NA
NSQIPShortTermOutcomes$Age <- as.numeric(NSQIPShortTermOutcomes$Age)
## Warning: NAs introduced by coercion
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == -99] <- "No"

NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 0] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 1] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 2] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 3] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 4] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 5] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 6] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 7] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 8] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 9] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 10] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 11] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 12] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 13] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 14] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 15] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 16] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 17] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 18] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 19] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 20] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 21] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 22] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 23] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 24] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 25] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 26] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 27] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 28] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 29] <- "Yes"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == 30] <- "Yes"
###Recoding Variables in DopertoD numbers > yes and any NA's to No

NSQIPShortTermOutcomes[NSQIPShortTermOutcomes$DOpertoD =="NA"]$DOpertoD <- "No"
NSQIPShortTermOutcomes$DOpertoD[NSQIPShortTermOutcomes$DOpertoD == NA] <- "No"

NSQIPShortTermOutcomes$DOpertoD <- as.character(NSQIPShortTermOutcomes$DOpertoD)
NSQIPShortTermOutcomes$DOpertoD[is.na(NSQIPShortTermOutcomes$DOpertoD)] <- "No"
#Ifelse function to create new column for serious complication and any complication
MISITTDemoTable <- 
  mutate(NSQIPShortTermOutcomes, SeriousComplication = ifelse(CDARREST == "Cardiac Arrest Requiring CPR", "Yes",
                                                              ifelse(CDMI == "Myocardial Infarction", "Yes",
                                                                     ifelse(OUPNEUMO == "Pneumonia", "Yes",
                                                                            ifelse(RENAINSF == "Progressive Renal Insufficiency", "Yes",
                                                                                   ifelse(OPRENAFL == "Acute Renal Failure", "Yes",
                                                                                          ifelse(PULEMBOL == "Pulmonary Embolism", "Yes",
                                                                                                 ifelse(OTHDVT == "DVT Requiring Therapy", "Yes",
                                                                                                        ifelse(RETURNOR == "Yes", "Yes",
                                                                                                               ifelse(ORGSPCSSI == "Organ/Space SSI", "Yes",
                                                                                                                      ifelse(PRSEPIS == "Yes", "Yes",
                                                                                                                             ifelse(REINTUB == "Unplanned Intubation", "Yes",
                                                                                                                                    ifelse(URNINFEC == "Urinary Tract Infection", "Yes",
                                                                                                                                           ifelse(DEHIS == "Wound Disruption", "Yes", "No"))))))))))))))
### Ifelse function to create new column for any complication
MISITTDemoTable1 <- MISITTDemoTable %>%
  mutate(MISITTDemoTable, AnyComplication = ifelse(CDARREST == "Cardiac Arrest Requiring CPR", "Yes",
                                                   ifelse(CDMI == "Myocardial Infarction", "Yes",
                                                          ifelse(OUPNEUMO == "Pneumonia", "Yes",
                                                                 ifelse(RENAINSF == "Progressive Renal Insufficiency", "Yes",
                                                                        ifelse(OPRENAFL == "Acute Renal Failure", "Yes",
                                                                               ifelse(PULEMBOL == "Pulmonary Embolism", "Yes",
                                                                                      ifelse(OTHDVT == "DVT Requiring Therapy", "Yes",
                                                                                             ifelse(RETURNOR == "Yes", "Yes",
                                                                                                    ifelse(ORGSPCSSI == "Organ/Space SSI", "Yes",
                                                                                                           ifelse(PRSEPIS == "Yes", "Yes",
                                                                                                                  ifelse(REINTUB == "Unplanned Intubation", "Yes",
                                                                                                                         ifelse(URNINFEC == "Urinary Tract Infection", "Yes",
                                                                                                                                ifelse(SUPINFEC == "Superficial Incisional SSI", "Yes",
                                                                                                                                       ifelse(FAILWEAN == "On Ventilator greater than 48 Hours", "Yes",
                                                                                                                                              ifelse(CNSCVA == "Stroke/CVA", "Yes",
                                                                                                                                                     ifelse(DEHIS == "Wound Disruption", "Yes", "No")))))))))))))))))
MISITTDemoTable1$PAN_APPROACH[MISITTDemoTable1$PAN_APPROACH =="MIS"] <- "MIS"
MISITTDemoTable1$PAN_APPROACH[MISITTDemoTable1$PAN_APPROACH =="MIS Converted to Open"] <- "MIS"
#### Subsetting cleaned data from one dataframe to a new dataframe
IntentiontotreatFinal <- 
  MISITTDemoTable1 %>%
  select(PAN_APPROACH, Age, SEX, BMI, RACE_NEW, ASACLAS, DOpertoD, Fistula.Grade, OPTIME, TOTHLOS, CDARREST, CDMI, NRENAINSF, OPRENAFL, OTHDVT, OUPNEUMO, PULEMBOL, WNDINFD, URNINFEC, DEHIS, STILLINHOSP, REOPERATION1, RETURNOR, REINTUB, ORGSPCSSI, OTHSYSEP, PRSEPIS, FAILWEAN, CNSCVA, SeriousComplication, AnyComplication)
## Changing any Unknowns/none assigned to NA
IntentiontotreatFinal[IntentiontotreatFinal =="None assigned"] <- NA
IntentiontotreatFinal[IntentiontotreatFinal =="Unknown"] <- NA
#### Labeling columns
var_label(IntentiontotreatFinal$SEX) <- "Sex"
var_label(IntentiontotreatFinal$RACE_NEW) <- "Race"
var_label(IntentiontotreatFinal$ASACLAS) <- "ASA Classification"
var_label(IntentiontotreatFinal$Fistula.Grade) <- "Fistula"
var_label(IntentiontotreatFinal$OPTIME) <- "Total operation time"
var_label(IntentiontotreatFinal$OUPNEUMO) <- "Number of Pneumonia Occurrences"
var_label(IntentiontotreatFinal$DOpertoD) <- "Mortality"
var_label(IntentiontotreatFinal$TOTHLOS) <- "Length of total hospital stay"
var_label(IntentiontotreatFinal$OUPNEUMO) <- "Occurrences Pneumonia"
var_label(IntentiontotreatFinal$PULEMBOL) <- "Occurrences Pulmonary Embolism"
var_label(IntentiontotreatFinal$WNDINFD) <- " Occurrences Deep Incisional SSI"
var_label(IntentiontotreatFinal$STILLINHOSP) <- "Still in Hospital > 30 Days"
var_label(IntentiontotreatFinal$REOPERATION1) <- "Unplanned Reoperation 1"
var_label(IntentiontotreatFinal$OTHSYSEP) <- "Occurrences Sepsis"
var_label(IntentiontotreatFinal$SeriousComplication) <- "Serious Complication"
var_label(IntentiontotreatFinal$AnyComplication) <- "Any Complication"
#Final Step to create demographic table
IntentiontotreatFinal %>%
  tbl_summary(
    by = PAN_APPROACH,
    digits = all_continuous() ~ 2,) %>%
  add_p(pvalue_fun = ~style_pvalue(.x, digits = 2))%>%
  bold_p() %>%
  add_overall() %>%
  modify_header(label ~ "**Variable**") %>%
  modify_spanning_header(c("stat_1", "stat_2") ~ "**NSQIP Short Term Outcomes**") %>%
  bold_labels() 
## 2 observations missing `PAN_APPROACH` have been removed. To include these observations, use `forcats::fct_explicit_na()` on `PAN_APPROACH` column before passing to `tbl_summary()`.
Variable Overall, N = 2,4061 NSQIP Short Term Outcomes p-value2
MIS, N = 9291 Open, N = 1,4771
Age 68.00 (60.00, 74.00) 69.00 (61.00, 76.00) 67.00 (60.00, 74.00) <0.001
Unknown 8 3 5
Sex 0.94
female 1,200 (50%) 462 (50%) 738 (50%)
male 1,206 (50%) 467 (50%) 739 (50%)
BMI 26.58 (23.41, 30.50) 26.79 (23.71, 30.89) 26.44 (23.22, 30.22) 0.011
Race 0.81
Black 241 (11%) 90 (11%) 151 (12%)
Other 90 (4.2%) 37 (4.4%) 53 (4.0%)
White 1,812 (85%) 706 (85%) 1,106 (84%)
Unknown 263 96 167
ASA Classification 0.23
1-No Disturb 11 (0.5%) 6 (0.6%) 5 (0.3%)
2-Mild Disturb 497 (21%) 208 (22%) 289 (20%)
3-Severe Disturb 1,732 (72%) 650 (70%) 1,082 (73%)
4-Life Threat 163 (6.8%) 63 (6.8%) 100 (6.8%)
Unknown 3 2 1
Mortality 27 (1.1%) 8 (0.9%) 19 (1.3%) 0.44
Fistula 0.003
Grade A 32 (1.3%) 8 (0.9%) 24 (1.6%)
Grade B 357 (15%) 164 (18%) 193 (13%)
Grade C 8 (0.3%) 1 (0.1%) 7 (0.5%)
No Fistula 1,976 (83%) 741 (81%) 1,235 (85%)
Unknown 33 15 18
Total operation time 232.00 (171.00, 312.00) 232.00 (178.00, 296.00) 232.00 (165.00, 324.00) 0.98
Length of total hospital stay 6.00 (5.00, 8.00) 5.00 (4.00, 7.00) 6.00 (5.00, 9.00) <0.001
CDARREST 0.57
Cardiac Arrest Requiring CPR 20 (0.8%) 6 (0.6%) 14 (0.9%)
No Complication 2,386 (99%) 923 (99%) 1,463 (99%)
CDMI >0.99
Myocardial Infarction 26 (1.1%) 10 (1.1%) 16 (1.1%)
No Complication 2,380 (99%) 919 (99%) 1,461 (99%)
NRENAINSF 6 (0.2%) 2 (0.2%) 4 (0.3%) >0.99
OPRENAFL 0.74
Acute Renal Failure 9 (0.4%) 4 (0.4%) 5 (0.3%)
No Complication 2,397 (100%) 925 (100%) 1,472 (100%)
OTHDVT 0.85
DVT Requiring Therapy 59 (2.5%) 24 (2.6%) 35 (2.4%)
No Complication 2,347 (98%) 905 (97%) 1,442 (98%)
Occurrences Pneumonia 0.78
No Complication 2,330 (97%) 898 (97%) 1,432 (97%)
Pneumonia 76 (3.2%) 31 (3.3%) 45 (3.0%)
Occurrences Pulmonary Embolism 0.48
No Complication 2,371 (99%) 918 (99%) 1,453 (98%)
Pulmonary Embolism 35 (1.5%) 11 (1.2%) 24 (1.6%)
Occurrences Deep Incisional SSI 0.33
Deep Incisional SSI 10 (0.4%) 2 (0.2%) 8 (0.5%)
No Complication 2,396 (100%) 927 (100%) 1,469 (99%)
URNINFEC >0.99
No Complication 2,349 (98%) 907 (98%) 1,442 (98%)
Urinary Tract Infection 57 (2.4%) 22 (2.4%) 35 (2.4%)
DEHIS 0.26
No Complication 2,399 (100%) 928 (100%) 1,471 (100%)
Wound Disruption 7 (0.3%) 1 (0.1%) 6 (0.4%)
Still in Hospital > 30 Days 21 (0.9%) 8 (0.9%) 13 (0.9%) >0.99
Unplanned Reoperation 1 93 (3.9%) 32 (3.4%) 61 (4.1%) 0.46
RETURNOR 93 (3.9%) 32 (3.4%) 61 (4.1%) 0.46
REINTUB 0.58
No Complication 2,353 (98%) 911 (98%) 1,442 (98%)
Unplanned Intubation 53 (2.2%) 18 (1.9%) 35 (2.4%)
ORGSPCSSI 0.99
No Complication 2,148 (89%) 830 (89%) 1,318 (89%)
Organ/Space SSI 258 (11%) 99 (11%) 159 (11%)
Occurrences Sepsis 0.85
No Complication 2,324 (97%) 896 (96%) 1,428 (97%)
Sepsis 82 (3.4%) 33 (3.6%) 49 (3.3%)
PRSEPIS 0.021
None 2,383 (99%) 926 (100%) 1,457 (99%)
Yes 23 (1.0%) 3 (0.3%) 20 (1.4%)
FAILWEAN 0.67
No Complication 2,357 (98%) 912 (98%) 1,445 (98%)
On Ventilator greater than 48 Hours 49 (2.0%) 17 (1.8%) 32 (2.2%)
CNSCVA 0.50
No Complication 2,397 (100%) 927 (100%) 1,470 (100%)
Stroke/CVA 9 (0.4%) 2 (0.2%) 7 (0.5%)
Serious Complication 508 (21%) 189 (20%) 319 (22%) 0.50
Any Complication 544 (23%) 198 (21%) 346 (23%) 0.25

1 Statistics presented: Median (IQR); n (%)

2 Statistical tests performed: Wilcoxon rank-sum test; chi-square test of independence; Fisher's exact test

##Creating New Column for Age breakdown
IntentiontotreatFinal <- 
  IntentiontotreatFinal %>%
  mutate(IntentiontotreatFinal, BMIB = ifelse(BMI >= 30, "Obese",
                                          ifelse(BMI <= 30, "Non-Obese", "NA")))
###Try removing 5-moribound from the odds ratio
IntentiontotreatFinal$ASACLAS[IntentiontotreatFinal$ASACLAS =="5-Moribund"] <- NA
###Creating table for logistic regression pan_approach
MISOR <- 
  IntentiontotreatFinal %>%
  mutate(IntentiontotreatFinal, Laparoscopic = ifelse(PAN_APPROACH =="MIS", "1",
                                                   ifelse(PAN_APPROACH =="Open", "0", "NA")))
### pan_approach --> numeric in the ITTMORTOR column before running logistic regression
MISOR$Laparoscopic <- as.numeric(MISOR$Laparoscopic)
##Univariant Model MISvsITT laparoscopic
UVMISOR <- MISOR %>%
  select(Laparoscopic, SEX, BMIB, RACE_NEW, ASACLAS) %>%
  tbl_uvregression(
    method = glm,
    y = Laparoscopic,
    method.args = list(family = binomial),
    exponentiate = TRUE,
    pvalue_fun = ~style_pvalue(.x, digits = 2)
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
####Multivariant analysis Laparoscopic
MISMVOR <- 
  glm(Laparoscopic ~ RACE_NEW + SEX + BMIB + ASACLAS, 
      data = MISOR,
      family = binomial("logit"), 
      na.action =na.omit
  )
TBLMVORMIS <-
  tbl_regression(MISMVOR, exponentiate = T,
                 pvalue_fun = ~style_pvalue(.x, digits = 2),
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
tbl_merge(
  list(UVMISOR, TBLMVORMIS),
  tab_spanner = c("**Univariable**", "**Multivariable**")
) %>%
  bold_labels() %>%
  italicize_levels()
Characteristic Univariable Multivariable
N OR1 95% CI1 p-value OR1 95% CI1 p-value
Sex 2,406
female
male 1.01 0.86, 1.19 0.91 1.00 0.84, 1.19 >0.99
BMIB 2,406
Non-Obese
Obese 1.16 0.97, 1.39 0.11 1.21 1.00, 1.47 0.054
Race 2,143
Black
Other 1.17 0.71, 1.92 0.53 1.22 0.74, 2.01 0.43
White 1.07 0.81, 1.42 0.63 1.09 0.83, 1.45 0.54
ASA Classification 2,403
1-No Disturb
2-Mild Disturb 0.60 0.17, 2.02 0.40 0.91 0.24, 3.72 0.89
3-Severe Disturb 0.50 0.14, 1.67 0.25 0.73 0.19, 2.98 0.64
4-Life Threat 0.52 0.15, 1.81 0.30 1.07 0.27, 4.51 0.93

1 OR = Odds Ratio, CI = Confidence Interval

###Creating table for logistic regression Anycomplication
MISAnycomplication <- 
  IntentiontotreatFinal %>%
  mutate(IntentiontotreatFinal, Anycomplication1 = ifelse(AnyComplication =="Yes", "1",
                                                   ifelse(AnyComplication =="No", "0", "NA")))
### AnyComplication --> numeric in the AnyComplication column before running logistic regression
MISAnycomplication$Anycomplication1 <- as.numeric(MISAnycomplication$Anycomplication1)
##Univariant Model AnyComplication
UVMISAnycomplicationOR <- MISAnycomplication %>%
  select(Anycomplication1, PAN_APPROACH, SEX, BMIB, RACE_NEW, ASACLAS) %>%
  tbl_uvregression(
    method = glm,
    y = Anycomplication1,
    method.args = list(family = binomial),
    exponentiate = TRUE,
    pvalue_fun = ~style_pvalue(.x, digits = 2)
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
####Multivariant analysis AnyComplication
MISMVORAnycomplication <- 
  glm(Anycomplication1 ~ PAN_APPROACH + RACE_NEW + SEX + BMIB + ASACLAS, 
      data = MISAnycomplication,
      family = binomial("logit"), 
      na.action =na.omit
  )
TBLAnycomplication <-
  tbl_regression(MISMVORAnycomplication, exponentiate = T,
                 pvalue_fun = ~style_pvalue(.x, digits = 2),
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
tbl_merge(
  list(UVMISAnycomplicationOR, TBLAnycomplication),
  tab_spanner = c("**Univariable**", "**Multivariable**")
) %>%
  bold_labels() %>%
  italicize_levels()
Characteristic Univariable Multivariable
N OR1 95% CI1 p-value OR1 95% CI1 p-value
PAN_APPROACH 2,406
MIS
Open 1.13 0.93, 1.38 0.23 1.07 0.86, 1.32 0.56
Sex 2,408
female
male 1.11 0.92, 1.35 0.28 1.12 0.91, 1.38 0.28
BMIB 2,408
Non-Obese
Obese 1.05 0.85, 1.29 0.66 1.02 0.81, 1.28 0.86
Race 2,145
Black
Other 0.65 0.33, 1.19 0.17 0.67 0.35, 1.24 0.22
White 0.92 0.67, 1.27 0.60 0.92 0.67, 1.27 0.61
ASA Classification 2,405
1-No Disturb
2-Mild Disturb 2.65 0.50, 48.8 0.36 1.95 0.35, 36.4 0.53
3-Severe Disturb 2.89 0.55, 53.2 0.31 2.05 0.37, 38.2 0.50
4-Life Threat 4.14 0.76, 77.0 0.18 2.82 0.49, 53.4 0.34

1 OR = Odds Ratio, CI = Confidence Interval

###Creating table for logistic regression serious complication
MISSeriouscomplication <- 
  IntentiontotreatFinal %>%
  mutate(IntentiontotreatFinal, SeriousComplication1 = ifelse(SeriousComplication =="Yes", "1",
                                                   ifelse(SeriousComplication =="No", "0", "NA")))
### SeriousComplication --> numeric in the serious complication column before running logistic regression
MISSeriouscomplication$SeriousComplication1 <- as.numeric(MISSeriouscomplication$SeriousComplication1)
##Univariant Model serious complication
UVMISSeriouscomplicationOR <- MISSeriouscomplication %>%
  select(SeriousComplication1, PAN_APPROACH, SEX, BMIB, RACE_NEW, ASACLAS) %>%
  tbl_uvregression(
    method = glm,
    y = SeriousComplication1,
    method.args = list(family = binomial),
    exponentiate = TRUE,
    pvalue_fun = ~style_pvalue(.x, digits = 2)
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
####Multivariant analysis serious complication
MISMVORSeriouscomplication <- 
  glm(SeriousComplication1 ~ PAN_APPROACH + RACE_NEW + SEX + BMIB + ASACLAS, 
      data = MISSeriouscomplication,
      family = binomial("logit"), 
      na.action =na.omit
  )
TBLSeriouscomplication <-
  tbl_regression(MISMVORSeriouscomplication, exponentiate = T,
                 pvalue_fun = ~style_pvalue(.x, digits = 2),
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
tbl_merge(
  list(UVMISSeriouscomplicationOR, TBLSeriouscomplication),
  tab_spanner = c("**Univariable**", "**Multivariable**")
) %>%
  bold_labels() %>%
  italicize_levels()
Characteristic Univariable Multivariable
N OR1 95% CI1 p-value OR1 95% CI1 p-value
PAN_APPROACH 2,406
MIS
Open 1.08 0.88, 1.32 0.46 1.03 0.83, 1.28 0.79
Sex 2,408
female
male 1.11 0.91, 1.35 0.31 1.11 0.90, 1.37 0.34
BMIB 2,408
Non-Obese
Obese 1.09 0.88, 1.35 0.44 1.06 0.84, 1.34 0.63
Race 2,145
Black
Other 0.69 0.35, 1.28 0.26 0.72 0.36, 1.35 0.32
White 0.98 0.71, 1.37 0.91 0.98 0.71, 1.38 0.91
ASA Classification 2,405
1-No Disturb
2-Mild Disturb 2.39 0.45, 44.2 0.41 1.76 0.32, 33.0 0.60
3-Severe Disturb 2.67 0.51, 49.0 0.35 1.90 0.34, 35.4 0.55
4-Life Threat 3.67 0.67, 68.3 0.22 2.37 0.41, 45.0 0.43

1 OR = Odds Ratio, CI = Confidence Interval

###Creating table for logistic regression Mortality
MISMortality <- 
  IntentiontotreatFinal %>%
  mutate(IntentiontotreatFinal, DOpertoD1 = ifelse(DOpertoD =="Yes", "1",
                                                   ifelse(DOpertoD =="No", "0", "NA")))
### Mortality --> numeric in the Mortality column before running logistic regression
MISMortality$DOpertoD1 <- as.numeric(MISMortality$DOpertoD1)
##Univariant Model Mortality
UVMISMortality <- MISMortality %>%
  select(DOpertoD1, PAN_APPROACH, SEX, BMIB, RACE_NEW, ASACLAS) %>%
  tbl_uvregression(
    method = glm,
    y = DOpertoD1,
    method.args = list(family = binomial),
    exponentiate = TRUE,
    pvalue_fun = ~style_pvalue(.x, digits = 2)
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x collapsing to unique 'x' values
## ℹ Input `tbl` is `map2(...)`.
## Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm):
## collapsing to unique 'x' values
####Multivariant analysis Mortality
MISMVORMortality <- 
  glm(DOpertoD1 ~ PAN_APPROACH + RACE_NEW + SEX + BMIB + ASACLAS, 
      data = MISMortality,
      family = binomial("logit"), 
      na.action =na.omit
  )
TBLMortality <-
  tbl_regression(MISMVORMortality, exponentiate = T,
                 pvalue_fun = ~style_pvalue(.x, digits = 2),
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm):
## collapsing to unique 'x' values

## Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm):
## collapsing to unique 'x' values
tbl_merge(
  list(UVMISMortality, TBLMortality),
  tab_spanner = c("**Univariable**", "**Multivariable**")
) %>%
  bold_labels() %>%
  italicize_levels()
Characteristic Univariable Multivariable
N OR1 95% CI1 p-value OR1 95% CI1 p-value
PAN_APPROACH 2,406
MIS
Open 1.50 0.68, 3.65 0.34 1.24 0.51, 3.30 0.64
Sex 2,408
female
male 1.07 0.50, 2.32 0.86 1.22 0.51, 3.02 0.65
BMIB 2,408
Non-Obese
Obese 1.32 0.56, 2.88 0.50 0.76 0.25, 1.97 0.59
Race 2,145
Black
Other 0.89 0.04, 7.06 0.92 1.05 0.05, 8.53 0.97
White 0.75 0.25, 3.23 0.65 0.79 0.26, 3.42 0.71
ASA Classification 2,405
1-No Disturb
2-Mild Disturb 95,049 0.00, NA 0.99 35,677 0.00, NA 0.99
3-Severe Disturb 164,271 0.00, NA 0.99 177,045 0.00, NA 0.99
4-Life Threat 594,355 0.00, NA 0.99 409,313 0.00, NA 0.99

1 OR = Odds Ratio, CI = Confidence Interval

###Creating table for logistic regression serious complication
MISReturnOR <- 
  IntentiontotreatFinal %>%
  mutate(IntentiontotreatFinal, RETURNOR1 = ifelse(RETURNOR =="Yes", "1",
                                                   ifelse(RETURNOR =="No", "0", "NA")))
### AnyComplication --> numeric in the serious complication column before running logistic regression
MISReturnOR$RETURNOR1 <- as.numeric(MISReturnOR$RETURNOR1)
##Univariant Model serious complication
UVMISReturnOR <- MISReturnOR %>%
  select(RETURNOR1, PAN_APPROACH, SEX, BMIB, RACE_NEW, ASACLAS) %>%
  tbl_uvregression(
    method = glm,
    y = RETURNOR1,
    method.args = list(family = binomial),
    exponentiate = TRUE,
    pvalue_fun = ~style_pvalue(.x, digits = 2)
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x glm.fit: fitted probabilities numerically 0 or 1 occurred
## ℹ Input `tbl` is `map2(...)`.
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: Problem with `mutate()` input `tbl`.
## x collapsing to unique 'x' values
## ℹ Input `tbl` is `map2(...)`.
## Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm):
## collapsing to unique 'x' values
####Multivariant analysis serious complication
MISMVORReturnOR <- 
  glm(RETURNOR1 ~ PAN_APPROACH + RACE_NEW + SEX + BMIB + ASACLAS, 
      data = MISReturnOR,
      family = binomial("logit"), 
      na.action =na.omit
  )
TBLReturnOR <-
  tbl_regression(MISMVORReturnOR, exponentiate = T,
                 pvalue_fun = ~style_pvalue(.x, digits = 2),
  ) %>%
  bold_p(t = 0.10) %>%
  bold_labels() %>%
  italicize_levels()
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
tbl_merge(
  list(UVMISReturnOR, TBLReturnOR),
  tab_spanner = c("**Univariable**", "**Multivariable**")
) %>%
  bold_labels() %>%
  italicize_levels()
Characteristic Univariable Multivariable
N OR1 95% CI1 p-value OR1 95% CI1 p-value
PAN_APPROACH 2,406
MIS
Open 1.21 0.79, 1.89 0.40 1.09 0.69, 1.75 0.73
Sex 2,408
female
male 1.22 0.80, 1.85 0.36 1.13 0.72, 1.78 0.58
BMIB 2,408
Non-Obese
Obese 0.81 0.49, 1.29 0.39 0.61 0.34, 1.04 0.081
Race 2,145
Black
Other 0.17 0.01, 0.85 0.088 0.17 0.01, 0.85 0.086
White 0.57 0.33, 1.05 0.056 0.55 0.31, 1.02 0.043
ASA Classification 2,405
1-No Disturb
2-Mild Disturb 118,230 0.02, 6,026,453,222,427,280,373,204,702,613,959,489,815,126,414,113,393,895,722,886,685,804,935,365,263,360 0.98 91,107 0.00, NA 0.98
3-Severe Disturb 256,828 0.00, NA 0.98 232,146 0.00, NA 0.98
4-Life Threat 295,272 0.06, 15,050,867,399,493,342,165,163,603,763,121,182,966,376,093,892,550,861,607,661,198,350,299,930,034,176 0.98 206,389 0.01, 334,840,329,407,747,723,578,845,935,567,899,486,870,654,799,029,570,408,296,079,931,929,020,384,713,637,888 0.98

1 OR = Odds Ratio, CI = Confidence Interval