Web access to knitted HTML output

We have decided to take a leap and try plot_ly and knit to html output for this milestone. The html page is hosted as Github Pages and is accessible in this address: https://tin6150.github.io/phw251_group_z/milestone4_groupZ.html

Project and milestone overview

{Pasted to group’s gdoc}

R setup and data preparation

(This code block omitted for brevity, please refer to source at our github repo )

Visualizations & Code

Rural Counties Deserving More HCAI Funding

Table 1 shows that the 5 counties we selected as deserving more HCAI funding.
They are the counties of Siskiyou, Inyo, Mariposa, Plumas and Modoc. All these 5 counties have low population density (they qualify as Rural per National Rural Development Partnership’s definition), have a high median age, and fairly high ratio of renters. More importantly, they have one of the highest percentage of chronic diseases mortality, and no HCAI fundings that are “In Closure” as of 2022-08-11.

As background reference, across all 58 CA counties, we found these statistics:

  • average population density: 665 person per square mile.
  • average rent:own ratio is: 64.7%
  • average age is: 38.5

Note that mortality rate is calculated based on the latest available population data: 2012.

viz_focus = viz_fund_dem_chron %>%
  filter( rural_class      == "rural",
          high_med_age     == TRUE 
          ##high_rental    == TRUE  
          )

focus_table = viz_focus %>%
  mutate( USD_amount = currency( Numeric_Cost, digits=0L)) %>%
  select( County, 
          pop12_sqmi,
          med_age,
          rent_own_ratio,
          pct,                    # prevalence,         
          USD_amount, 
  ) %>% 
  arrange( desc( pct )) %>%
  rename(
    `Pop Density`       = pop12_sqmi,
    `Median Age`        = med_age,
    `Rent:Own Ratio`    = rent_own_ratio,
    `% Chronic`         = pct,
    `HCAI Fund in 2022` = USD_amount
  ) %>%  
  head( 5 ) 

kable( focus_table,
       format      = "html",
       booktabs    = T,
       digits      = c(0,1,1,2,2,0L),
       align       = c('lccccr'),
       format.args = list(big.mark=','),
       caption = "Rural Counties with high median age, rental ratio, and chronic disease rate",
       )
Rural Counties with high median age, rental ratio, and chronic disease rate
County Pop Density Median Age Rent:Own Ratio % Chronic HCAI Fund in 2022
Siskiyou 7.1 46.8 0.54 2.86 $0
Inyo 1.8 45.5 0.57 1.88 $0
Mariposa 12.6 49.2 0.47 1.72 $0
Plumas 7.7 49.5 0.44 1.69 $0
Modoc 2.3 46.0 0.46 1.43 $0

Mortality Rate by County

Figure 1 is a bar graph of Mortality Rate for Chronic diseases (as defined by CDC) across 11 rural counties (as defined by National Rural Development Partnership) The 5 counties of focus have the highest mortality rates in this group.

Note that we don’t have disease data for Alpine or Sierra county.

chronic_focus_counties = inner_join(
    demographics_chronic,
    rural_counties,
    by = "County"                   ) %>%
  mutate( ctyColor = case_when(
    County == "Siskiyou" ~ "red", 
    County == "Inyo"     ~ "darkorange" , 
    County == "Mariposa" ~ "blue", 
    County == "Plumas"   ~ "darkblue",
    County == "Modoc"    ~ "darkcyan",
    TRUE                 ~ "rgb(187, 216, 228)"
  ) )


fig3 = plot_ly( data = chronic_focus_counties ) %>%
    add_trace(
            x = ~County,
            y = ~pct,
            name = 'Chronic Mortality Rates by Counties',
            marker = list(color = ~ctyColor),
            hoverinfo = "text",
            text = ~paste(round(pct, 1), "%" ),  
            type = 'bar') %>%
   layout(
            title = "Chronic Mortality Rates For California's Rural Counties", 
            yaxis = list( title="% Mortality Rate"),
            xaxis = list( title="County", categoryorder='total descending' )
         )

fig3

Chronic disease mortality rates vs HCAI funding

Figure 2: The following boxplot summarizes chronic disease mortality rates from all CA counties, grouped according to HCAI funding amounts for in closure projects as of August 2022. The funding amounts were categorized as “high” if they were above the mean amount, low if they were below the mean, and “no funding” if no funding for in closure projects was reported. Variability of mortality rate is highest for counties in the “No funding” category, quality/predictability likely will increase with HCAI funding.

funding_chronic <- funding_data %>% 
  filter( `OSHPD Project Status` == "In Closure") %>%
  filter( `Data Generation Date` == as_date( "2022-08-11")) %>%
  mutate(funding_amount = case_when(
    Numeric_Cost > 12239849 ~ "High Funding", 
    Numeric_Cost == 0 ~ "No Funding", 
    Numeric_Cost < 12239849 ~ "Low Funding"
  )) %>%
  inner_join(demographics_chronic, funding_data_all_counties, by = "County") %>%
  select(pct, County, funding_amount, rural_class, Numeric_Cost)

plot_ly(
  funding_chronic,
  y=~pct,
  color= ~funding_amount,
  type="box"
) %>%
   layout(
    title="Chronic Disease Mortality Rates & HCAI Funding",
    yaxis=list(title="Chronic Disease Rate"))

Table showing most common disease by rural county

Table 2 shows the most common chronic disease in each of the rural counties, while also showing the number of people who have the illness in the year 2020. The counties of Alpine and Sierra did not have chronic disease data available. As we expand funding in the 5 select counties of focus, special emphasis should be placed on Heart Disease, as that’s the most common chronic illness causing high mortality. *HTD= Heart Disease, CAN= Cancer

table_data_e<- inner_join(rural_not_rural, chronic_mortality_data, by= "County") %>% 
select(c("County", "rural_class", "Cause","Count", "Year")) %>% filter(Year%in%2020) %>% 
filter(rural_class=="rural") %>% 
group_by(County,Cause) %>% summarize(count_cause=sum(Count)) %>% arrange(County,desc(c(count_cause))) %>% slice(c(1,11,21,31,41,51,61,71,81,91,101))

table_data_e[1,2]<-"Not Available"
table_data_e[9,2]<-"Not Available"

common_chronic<- kable(table_data_e, col.names=c("County", "Chronic Disease", "Number Reported"),
digits=0, booktabs=T, escape=F, align="ccc", caption="Most Common Chronic Disease by Rural County in 2020")
common_chronic
Most Common Chronic Disease by Rural County in 2020
County Chronic Disease Number Reported
Alpine Not Available 0
Colusa HTD 172
Inyo HTD 226
Lassen HTD 352
Mariposa HTD 200
Modoc HTD 68
Mono CAN 22
Plumas HTD 226
Sierra Not Available 0
Siskiyou CAN 756
Trinity CAN 62