Expand this to see code
library(tidyverse)
library(janitor)
library(DT)We want to analyze the Vaginal delivery rate for “uncomplicated” births, using the list of codes that indicate vaginal deliveries. The list of codes originally came from IQI 22 Vaginal Birth After Cesarean (VBAC) Delivery Rate, Uncomplicated but are repurposed to be more general.
This is the definition we will use for vaginal deliveries:
“Vaginal births per 1,000 deliveries identified by VAGDELP out of deliveries identified by DELOCMD. Excludes deliveries with complications (abnormal presentation, preterm delivery, fetal death, multiple gestation, or breech presentation).”
Loading libraries.
library(tidyverse)
library(janitor)
library(DT)We previously created a data set that flagged vaginal deliveries in the Categorization notebook.. We will need to import that data to this notebook so that we can do some analysis.
tx_deliveries_vaginal <- read_rds("../data-processed/vagdel.rds")Additionally, since our breakdown involves breaking down these rates by hospital, we need some of the lists that we created in the Stored Lists notebook.These lists group by brand for the hospital as well as distinguish whether a hospital is in the Texas Medical Center.
# list of Texas Medical Center hospitals
tmc_list <- read_rds("../data-published/technical-specs/tmc.rds") |> pull(name)
# brand and unaffiliated lists
harris_health_list <- read_rds("../data-published/technical-specs/harris_health.rds") |> pull(name)
hca_list <- read_rds("../data-published/technical-specs/hca.rds") |> pull(name)
houston_methodist_list <- read_rds("../data-published/technical-specs/houston_methodist.rds") |> pull(name)
memorial_hermann_list <- read_rds("../data-published/technical-specs/memorial_hermann.rds") |> pull(name)
unaffiliated_list <- read_rds("../data-published/technical-specs/unaffiliated.rds") |> pull(name)Here I’m going to define some functions that will help us to make some graphs with varying parts of the data.
First, we’ll make a function that allows us to add the vaginal delivery rate.
add_vagdel_calc <- function(.data, num_del) {
.data |>
summarize(CNT = n()) |>
pivot_wider(names_from = VAGDEL, values_from = CNT) |>
rename(
NON_VAGDEL_CNT = "FALSE",
VAGDEL_CNT = "TRUE"
) |>
mutate(
TOTAL = NON_VAGDEL_CNT + VAGDEL_CNT
) |>
filter(
TOTAL > 30
) |>
mutate(
# this gives us the percentage of total deliveries that are VAGDEL
VAGDEL_RATE = round_half_up((VAGDEL_CNT / TOTAL) * 100, 1)
) |>
mutate(
# we want to create a column that will use the rate we previously
# calculated to give us a number out of how many deliveries would appear
# as VAGDEL -- use an adjustable value so I don't have to change this
# if we decide on a different number
VAGDEL_DEL_PER = round_half_up((VAGDEL_CNT / TOTAL) * num_del, 1)
)
}We are also interested in the percentage of mothers that used Medicaid as their payment source for their vaginal delivery. We’ll create a function that adds this rate.
add_medicaid <- function(.data, num_del) {
.data |>
group_by(YR, VAGDEL_MC_CATEGORY) |>
summarize(CNT = n()) |>
pivot_wider(names_from = VAGDEL_MC_CATEGORY, values_from = CNT) |>
mutate(
TOTAL_MC = NONVAGDEL_MC + VAGDEL_MC,
TOTAL_NONMC = NONVAGDEL_NONMC + VAGDEL_NONMC
) |>
filter(TOTAL_MC > 30 | TOTAL_NONMC > 30) |>
mutate(
MC_DEL_PER = round_half_up((VAGDEL_MC / TOTAL_MC) * num_del, 1),
NONMC_DEL_PER = round_half_up((VAGDEL_NONMC / TOTAL_NONMC) * num_del, 1)
) |>
pivot_longer(
cols = c(MC_DEL_PER, NONMC_DEL_PER),
names_to = "DEL_PER_TYPE",
values_to = "DEL_PER"
)
}Let’s also make a function that provides a template for what the individual hospital graphs will look like.
create_hosp_graph <- function(.data) {
.data |>
ggplot(aes(x = YR, y = VAGDEL_DEL_PER)) +
geom_col() +
scale_y_continuous(limits = c(0, 800)) +
geom_text(aes(label = VAGDEL_DEL_PER), vjust = 1.5, color = "white", size = 3) +
facet_wrap(~ FAC_NAME, ncol = 2) +
theme(
legend.position = "bottom"
)
}We can make our lives so much easier by making a function for each individual graph, similar to the one above, that also includes race.
First let’s define some colors that we’ll use for the race graphs. We want these colors to be consistent across all of the plots. We are using colors based on a Washington Post article on the subject.
race_colors <- c(
"Hispanic" = "#ecda5c",
"American Indian" = "#a4c589",
"Asian or Pacific Islander" = "#c69cc1",
"Black" = "#d89d88",
"White" = "#8eb3be",
"Other" = "#c8ad68"
)Now we can build a function to create race graphs using these specified colors.
create_race_graph <- function(.data) {
.data |>
ggplot(aes(x = YR, y = VAGDEL_DEL_PER)) +
geom_point(aes(color = MOD_RACE)) +
geom_line(aes(color = MOD_RACE, group = MOD_RACE)) +
scale_y_continuous(limits = c(0, 800)) +
scale_color_manual(values = race_colors, name = "Race") +
facet_wrap(~ FAC_NAME, ncol = 2) +
theme(
legend.position = "bottom"
)
}In order to showcase the data visually, there are some things we have to do to the data set in order to prepare it to be plotted/shown in a table. This includes making a column for the rate per year. We will do this by hospital, but this might not be relevant to certain tables.
ahrq_vaginal_rate_tx <- tx_deliveries_vaginal |>
group_by(YR, VAGDEL) |>
add_vagdel_calc(1000)
ahrq_vaginal_rate_txNow, plot.
gavdel_yr_tx <- ahrq_vaginal_rate_tx |>
ggplot(aes(x = YR, y = VAGDEL_DEL_PER)) +
geom_col() +
scale_y_continuous(limits = c(0, 800)) +
geom_text(aes(label = VAGDEL_DEL_PER), vjust = 1.5, color = "white") +
labs(
title = "Rate of vaginal deliveries by year in Texas",
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries in all of Texas. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries per 1,000 deliveries",
caption = "Source: Texas Inpatient Public Use Data File"
) +
theme_minimal()
ggsave("../data-published/figures/vagdel/vagdel-yr-tx.png", width = 6, height = 6, units = "in")Saved Version:

We are interested in the number of vaginal deliveries that are paid for by Medicaid in all of Texas. We need to add the rate per year and then plot by year. First, let’s add the rate.
vaginal_mc_tx <- tx_deliveries_vaginal |>
add_medicaid(1000)
vaginal_mc_txNow, plot by year.
vagdel_mc_tx <- vaginal_mc_tx |>
ggplot(aes(x = YR, y = DEL_PER, group = DEL_PER_TYPE)) +
geom_point(aes(color = DEL_PER_TYPE)) +
geom_line(aes(color = DEL_PER_TYPE)) +
scale_y_continuous(limits = c(0, 800)) +
scale_color_discrete(labels = c("With Medicaid", "Without Medicaid"), name = "Rate of vaginal deliveries") +
labs(
title = str_wrap("Rate of vaginal deliveries for Medicaid cases in Texas"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries within a specific insurance payment group (Medicaid vs. Non-Medicaid). The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
) +
theme_minimal()
ggsave("../data-published/figures/vagdel/vagdel-mc-tx.png", width = 8, height = 6, units = "in")Saved Version:

Need to limit the statewide data to just Harris County like we had done in the cleaning notebook.
ahrq_vaginal_rate_harris <- tx_deliveries_vaginal |>
filter(FAC_CNTY == "Harris") |>
group_by(YR, VAGDEL) |>
add_vagdel_calc(1000)
ahrq_vaginal_rate_harrisWe can now plot it similar to how we did statewide.
ahrq_vaginal_rate_harris |>
ggplot(aes(x = YR, y = VAGDEL_DEL_PER)) +
geom_col() +
scale_y_continuous(limits = c(0, 800)) +
geom_text(aes(label = VAGDEL_DEL_PER), vjust = 1.5, color = "white") +
labs(
title = "Rate of vaginal deliveries by year in Harris County",
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries in Harris County. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000)",
caption = "Source: Texas Inpatient Public Use Data File"
) +
theme_minimal()
ggsave("../data-published/figures/vagdel/vagdel-yr-harris.png")Saved Version:

We are interested in the same analysis for percentage of mothers that paid with Medicaid for their vaginal delivery but specifically for Harris County. We need to filter for Harris County cases and then apply the same steps.
vaginal_mc_harris <- tx_deliveries_vaginal |>
filter(FAC_CNTY == "Harris") |>
add_medicaid(1000)
vaginal_mc_harrisNow, plot.
vagdel_mc_harris <- vaginal_mc_harris |>
ggplot(aes(x = YR, y = DEL_PER, group = DEL_PER_TYPE)) +
geom_point(aes(color = DEL_PER_TYPE)) +
geom_line(aes(color = DEL_PER_TYPE)) +
scale_y_continuous(limits = c(0, 800)) +
scale_color_discrete(labels = c("With Medicaid", "Without Medicaid"), name = "Rate of vaginal deliveries") +
labs(
title = str_wrap("Rate of vaginal deliveries for Medicaid cases in Harris County"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries within a specific insurance payment group (Medicaid vs. Non-Medicaid). The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
) +
theme_minimal()
ggsave("../data-published/figures/vagdel/vagdel-mc-harris.png", width = 8, height = 6, units = "in")Saved Version:

Let’s compare the Cesarean delivery rate across different hospitals in Harris County. We’ll prep the data so that it includes the facility’s name and ID.
ahrq_vaginal_rate_hosp <- tx_deliveries_vaginal |>
filter(FAC_CNTY == "Harris") |>
group_by(YR, THCIC_ID, FAC_NAME, VAGDEL) |>
add_vagdel_calc(1000)
ahrq_vaginal_rate_hosp |> datatable()Now we can plot all of the individual hospitals into separate graphs. We’ll group up individual graphs by brand and by location.
Here are the brands of hospitals found in the Harris County data:
Let’s take a look at the Harris Health hospitals.
vagdel_hosp_harris_health <- ahrq_vaginal_rate_hosp |>
filter(
FAC_NAME %in% harris_health_list
) |>
create_hosp_graph() +
labs(
title = str_wrap("Rate of vaginal deliveries by year for Harris Health hospitals"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries at each Harris Health hospital. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
)
ggsave("../data-published/figures/vagdel/vagdel-hosp-harris-health.png", width = 8, height = 4, units = "in")Saved Version:

Same with HCA Houston Healthcare hospitals.
vagdel_hosp_hca <- ahrq_vaginal_rate_hosp |>
filter(
FAC_NAME %in% hca_list
) |>
create_hosp_graph() +
labs(
title = str_wrap("Rate of vaginal deliveries by year for HCA Houston Healthcare hospitals"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries at each HCA Houston Healthcare hospital. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
)
ggsave("../data-published/figures/vagdel/vagdel-hosp-hca.png")Saved Version:

Houston Methodist hospitals next.
vagdel_hosp_houston_methodist <- ahrq_vaginal_rate_hosp |>
filter(
FAC_NAME %in% houston_methodist_list
) |>
create_hosp_graph() +
labs(
title = str_wrap("Rate of vaginal deliveries by year for Houston Methodist hospitals"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries at each Houston Methodist hospital. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
)
ggsave("../data-published/figures/vagdel/vagdel-hosp-houston-methodist.png")Saved Version:

Finally, Memorial Hermann hospitals.
vagdel_hosp_memorial_hermann <- ahrq_vaginal_rate_hosp |>
filter(
FAC_NAME %in% memorial_hermann_list
) |>
create_hosp_graph() +
labs(
title = str_wrap("Rate of vaginal deliveries by year for Memorial Hermann hospitals"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries at each Memorial Hermann hospital. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
)
ggsave("../data-published/figures/vagdel/vagdel-hosp-memorial-hermann.png", width = 8, height = 8, units = "in")Saved Version:

There are some hospitals in Harris County that don’t have other affiliated hospitals across the county. We will put them all into another set of graphs.
vagdel_hosp_unaffiliated <- ahrq_vaginal_rate_hosp |>
filter(
FAC_NAME %in% unaffiliated_list
) |>
create_hosp_graph() +
labs(
title = str_wrap("Rate of vaginal deliveries by year for unaffiliated hospitals"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries at each unaffiliated hospital. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
)
ggsave("../data-published/figures/vagdel/vagdel-hosp-unaffiliated.png", width = 8, height = 6, units = "in")Saved Version:

If we want to look at the data for Harris and Texas in one graph, we can plot Harris and Texas as two separate lines.
First, we need to put the Texas and Harris data into one data frame.
ahrq_vaginal_rate_combined <- ahrq_vaginal_rate_harris |>
add_column(CATEGORY = "Harris") |>
bind_rows(ahrq_vaginal_rate_tx) |>
# at this point, any unfilled category entry is a Texas entry
mutate(
CATEGORY = if_else(is.na(CATEGORY), "Texas", CATEGORY)
)
ahrq_vaginal_rate_combinedNow we can plot with the grouping being determined by the CATEGORY value.
vagdel_harris_tx <- ahrq_vaginal_rate_combined |>
ggplot(aes(x = YR, y = VAGDEL_DEL_PER)) +
geom_point(aes(color = CATEGORY)) +
geom_line(aes(color = CATEGORY, group = CATEGORY)) +
scale_y_continuous(limits = c(0, 800)) +
scale_color_discrete(name = "Category") +
labs(
title = str_wrap("Rate of vaginal deliveries in Harris County and Texas"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries in Texas broadly and Harris County specifically. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
) +
theme_minimal()
ggsave("../data-published/figures/vagdel/vagdel-harris-tx.png")Saved Version:

Similar to the last section, we want to see how the percentage of vaginal deliveries paid for by Medicaid differs between Texas and Harris County. First, we need to combine the data we had previously for both Texas and Harris County.
vaginal_mc_combined <- vaginal_mc_harris |>
add_column(CATEGORY = "Harris") |>
bind_rows(vaginal_mc_tx) |>
# at this point, any unfilled category entry is a Texas entry
mutate(
CATEGORY = if_else(is.na(CATEGORY), "Texas", CATEGORY)
) |>
mutate(
DEL_PER_TYPE = paste(toupper(CATEGORY), DEL_PER_TYPE, sep = "_")
) |>
select(!CATEGORY)
vaginal_mc_combinedNow, plot.
vaginal_mc_combined |>
ggplot(aes(x = YR, y = DEL_PER, group = DEL_PER_TYPE)) +
geom_point(aes(color = DEL_PER_TYPE)) +
geom_line(aes(color = DEL_PER_TYPE)) +
scale_y_continuous(limits = c(0, 800)) +
scale_color_discrete(labels = c("Harris County with Medicaid", "Harris County without Medicaid", "Texas with Medicaid", "Texas without Medicaid"), name = "Area + With or Without Medicaid?") +
labs(
title = str_wrap("Rate of vaginal deliveries by Medicaid in Harris County and Texas"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries within a specific insurance payment group (Medicaid vs. Non-Medicaid). The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File",
) +
theme_minimal()
One other facet grouping we wanted to look at was Harris County hospitals in the Medical Center area versus outside of the Medical Center area. We imported this list at the top of this notebook.
Let’s create a new data frame that distinguishes whether a hospital is in the Medical Center or not.
ahrq_vaginal_rate_tmc <- tx_deliveries_vaginal |>
mutate(
TMC = if_else(FAC_NAME %in% tmc_list, T, F)
) |>
group_by(YR, TMC, VAGDEL) |>
add_vagdel_calc(1000)
ahrq_vaginal_rate_tmcNow we can plot the comparison for vaginal delivery rate between hospitals in the Medical Center area and not in the Medical Center area.
vagdel_tmc <- ahrq_vaginal_rate_tmc |>
ggplot(aes(x = YR, y = VAGDEL_DEL_PER)) +
geom_point(aes(color = TMC)) +
geom_line(aes(color = TMC, group = TMC)) +
scale_y_continuous(limits = c(0, 800)) +
scale_color_discrete(name = "In Medical Center?", labels = c("False", "True")) +
labs(
title = str_wrap("Rate of vaginal deliveries in the Texas Medical Center"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries within the specific area (TMC vs. Non-TMC). The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
) +
theme_minimal()
ggsave("../data-published/figures/vagdel/vagdel-tmc.png")Saved Version:

We previously redefined the MOD_RACE categories to also include the difference between Hispanic and non-Hispanic individuals. This was done in the Categorization notebook.
Prep for plotting.
ahrq_vaginal_rate_tx_race <- tx_deliveries_vaginal |>
group_by(YR, MOD_RACE, VAGDEL) |>
add_vagdel_calc(1000)
ahrq_vaginal_rate_tx_raceNow we try to plot this.
vagdel_race_yr_tx <- ahrq_vaginal_rate_tx_race |>
ggplot(aes(x = YR, y = VAGDEL_DEL_PER))+
geom_point(aes(color = MOD_RACE)) +
geom_line(aes(color = MOD_RACE, group = MOD_RACE)) +
scale_color_manual(values = race_colors, name = "Race") +
scale_y_continuous(limits = c(0, 800)) +
labs(
title = "Rate of vaginal deliveries by year and race in Texas",
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries in Texas with respect to race. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
) +
theme_minimal()
ggsave("../data-published/figures/vagdel/vagdel-race-yr-tx.png", width = 8, height = 6, units = "in")Saved Version:

We can do a similar plot for just Harris County hospitals. First, prep the data.
ahrq_vaginal_rate_harris_race <- tx_deliveries_vaginal |>
filter(FAC_CNTY == "Harris") |>
group_by(YR, MOD_RACE, VAGDEL) |>
add_vagdel_calc(1000)
ahrq_vaginal_rate_harris_raceThere are much fewer American Indian cases than other races.
Now, plot.
vagdel_race_yr_harris <- ahrq_vaginal_rate_harris_race |>
ggplot(aes(x = YR, y = VAGDEL_DEL_PER)) +
geom_point(aes(color = MOD_RACE)) +
geom_line(aes(color = MOD_RACE, group = MOD_RACE)) +
scale_y_continuous(limits = c(0, 800)) +
scale_color_manual(values = race_colors, name = "Race") +
labs(
title = "Rate of vaginal deliveries by year and race in Harris County",
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries in Harris County with respect to race. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
) +
theme_minimal()
ggsave("../data-published/figures/vagdel/vagdel-race-yr-harris.png")Saved Version:

Look at individual hospitals now also with race. First, prep the data.
ahrq_vaginal_rate_hosp_race <- tx_deliveries_vaginal |>
filter(FAC_CNTY == "Harris") |>
group_by(YR, THCIC_ID, MOD_RACE, FAC_NAME, VAGDEL) |>
add_vagdel_calc(1000)
ahrq_vaginal_rate_hosp_raceThis section will look at all of the Harris Health hospitals with race data included.
vagdel_hosp_race_harris_health <- ahrq_vaginal_rate_hosp_race |>
filter(FAC_NAME %in% harris_health_list) |>
create_race_graph() +
labs(
title = str_wrap("Rate of vaginal deliveries by year and race for Harris Health hospitals"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries in Harris Health hospitals with respect to race. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
)
ggsave("../data-published/figures/vagdel/vagdel-hosp-race-harris-health.png", width = 8, height = 6, units = "in")Saved Version:

Now, HCA Houston Healthcare hospitals.
vagdel_hosp_race_hca <- ahrq_vaginal_rate_hosp_race |>
filter(
FAC_NAME %in% hca_list
) |>
create_race_graph() +
labs(
title = str_wrap("Rate of vaginal deliveries by year and race for HCA Houston Healthcare hospitals"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries in HCA Houston Healthcare hospitals with respect to race. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
)
ggsave("../data-published/figures/vagdel/vagdel-hosp-race-hca.png", height = 8, width = 8, units = "in")Saved Version:

Houston Methodist hospitals.
vagdel_hosp_race_houston_methodist <- ahrq_vaginal_rate_hosp_race |>
filter(
FAC_NAME %in% houston_methodist_list
) |>
create_race_graph() +
labs(
title = str_wrap("Rate of vaginal deliveries by year and race for Houston Methodist hospitals"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries in Houston Methodist hospitals with respect to race. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
)
ggsave("../data-published/figures/vagdel/vagdel-hosp-race-houston-methodist.png", height = 8, width = 8, units = "in")Saved Version:

Finally, Memorial Hermann hospitals.
vagdel_hosp_race_memorial_hermann <- ahrq_vaginal_rate_hosp_race |>
filter(
FAC_NAME %in% memorial_hermann_list
) |>
create_race_graph() +
labs(
title = str_wrap("Rate of vaginal deliveries by year and race for Memorial Hermann hospitals"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries in Memorial Hermann hospitals with respect to race. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
)
ggsave("../data-published/figures/vagdel/vagdel-hosp-race-memorial-hermann.png", height = 8, width = 8, units = "in")Saved Version:

Here are the race breakdowns for all of the hospitals that don’t fall under a brand.
vagdel_hosp_race_unaffiliated <- ahrq_vaginal_rate_hosp_race |>
filter(
FAC_NAME %in% unaffiliated_list
) |>
create_race_graph() +
labs(
title = str_wrap("Rate of vaginal deliveries by year and race for unaffiliated hospitals"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries in unaffiliated hospitals with respect to race. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
)
ggsave("../data-published/figures/vagdel/vagdel-hosp-race-unaffiliated.png", height = 8, width = 8, units = "in")Saved Version:

We will also compare by race for the hospitals in the Medical Center area and for those outside of the Medical Center area.
First, let’s create a data frame that determines whether the hospital is in the Medical Center and include considerations of race and ethnicity.
ahrq_vaginal_rate_tmc_race <- tx_deliveries_vaginal |>
mutate(
TMC = if_else(FAC_NAME %in% tmc_list, T, F)
) |>
group_by(YR, TMC, MOD_RACE, VAGDEL) |>
add_vagdel_calc(1000)
ahrq_vaginal_rate_tmc_raceNow we can create two graphs side by side so that we can compare the differences for race between whether a hospital is in the Medical Center or not.
tmc_labels <- c("FALSE" = "Not in Medical Center", "TRUE" = "In Medical Center")
vagdel_tmc_race <- ahrq_vaginal_rate_tmc_race |>
ggplot(aes(x = YR, y = VAGDEL_DEL_PER)) +
geom_point(aes(color = MOD_RACE)) +
geom_line(aes(color = MOD_RACE, group = MOD_RACE)) +
scale_color_manual(values = race_colors, name = "Race") +
scale_y_continuous(limits = c(0, 800)) +
facet_wrap(~ TMC, labeller = as_labeller(tmc_labels)) +
labs(
title = str_wrap("Rate of vaginal deliveries by year and race in the Texas Medical Center"),
subtitle = str_wrap("The ratio is calculated using the number of vaginal deliveries both in and outside of the Texas Medical Center with respect to race. The rate is presented per 1,000 deliveries."),
x = "Year", y = "Number of vaginal deliveries (per 1,000 deliveries)",
caption = "Source: Texas Inpatient Public Use Data File"
) +
theme(
legend.position = "bottom"
)
ggsave("../data-published/figures/vagdel/vagdel-race-tmc.png", height = 6, width = 8, units = "in")Saved Version:
