Image from CDC Website

Image from CDC Website

Introduction

The 500 cities datasets from the Centers for Disease Control and Prevention (CDC) contains estimates of 27 measures of chronic disease with a focus on unhealthy behaviors, health outcomes and prevention measures from 500 cities across the United States. The dataset consists of 16 variables listed in the table below.

Variable Description
Year Numeric, Year
Stateabbr Character, State abbreviation
StateDesc Character, State name
Region Character, Region in US
CityName Character, City name
GeographicLevel Character, Distinguishes between City or Census Tract
DataSource Character, Data source
Category Character, Health topic – outcome, behavior, prevention
Measure Character, Full description of health measure
DataValueTypeID Character, Identifier for data value type
Data_Value_Type Character, Data value type - crude or age-adjusted prevalence
Data_Value Numeric, Data Value
PopulationCount Numeric, Population
CategoryID Character, Identifier for the health category/topic
Measure Character, Identifier for measure
Short_Question_Text Character, Short name for the measure

The visualizations in this project compare the State of Kansas with its neighbors and also compare cities within the state of Kansas. The final visualization is a faceted bar chart showing the prevalence of four risk factors for heart disease, which according to the CDC is the leading cause of death in the United States. Specifically, it looks at the prevalence of obesity, smoking, high cholesterol, and high blood pressure across the six Kansas cities included in the dataset.

Loading libraries

library(RColorBrewer)
library(tidyverse)

Reading in the data

df <- read_csv("500CitiesHealthIndicatorsRegions.cdc.csv")

Cleaning the data

names(df) <- tolower(names(df)) #making all headers lower case
names(df) <- gsub(" ","",names(df)) #removing spaces between header names
head(df)
## # A tibble: 6 × 16
##    year stateabbr state…¹ region cityn…² geogr…³ datas…⁴ categ…⁵ measure datav…⁶
##   <dbl> <chr>     <chr>   <chr>  <chr>   <chr>   <chr>   <chr>   <chr>   <chr>  
## 1  2017 CA        Califo… West   Hawtho… Census… BRFSS   Health… Arthri… CrdPrv 
## 2  2017 CA        Califo… West   Hawtho… City    BRFSS   Unheal… Curren… CrdPrv 
## 3  2017 CA        Califo… West   Hayward City    BRFSS   Health… Corona… AgeAdj…
## 4  2017 CA        Califo… West   Hayward City    BRFSS   Unheal… Obesit… CrdPrv 
## 5  2017 CA        Califo… West   Hemet   City    BRFSS   Preven… Choles… AgeAdj…
## 6  2017 CA        Califo… West   Indio   Census… BRFSS   Health… Arthri… CrdPrv 
## # … with 6 more variables: data_value_type <chr>, data_value <dbl>,
## #   populationcount <dbl>, categoryid <chr>, measureid <chr>,
## #   short_question_text <chr>, and abbreviated variable names ¹​statedesc,
## #   ²​cityname, ³​geographiclevel, ⁴​datasource, ⁵​category, ⁶​datavaluetypeid

Exploring the dataset

head(df)
## # A tibble: 6 × 16
##    year stateabbr state…¹ region cityn…² geogr…³ datas…⁴ categ…⁵ measure datav…⁶
##   <dbl> <chr>     <chr>   <chr>  <chr>   <chr>   <chr>   <chr>   <chr>   <chr>  
## 1  2017 CA        Califo… West   Hawtho… Census… BRFSS   Health… Arthri… CrdPrv 
## 2  2017 CA        Califo… West   Hawtho… City    BRFSS   Unheal… Curren… CrdPrv 
## 3  2017 CA        Califo… West   Hayward City    BRFSS   Health… Corona… AgeAdj…
## 4  2017 CA        Califo… West   Hayward City    BRFSS   Unheal… Obesit… CrdPrv 
## 5  2017 CA        Califo… West   Hemet   City    BRFSS   Preven… Choles… AgeAdj…
## 6  2017 CA        Califo… West   Indio   Census… BRFSS   Health… Arthri… CrdPrv 
## # … with 6 more variables: data_value_type <chr>, data_value <dbl>,
## #   populationcount <dbl>, categoryid <chr>, measureid <chr>,
## #   short_question_text <chr>, and abbreviated variable names ¹​statedesc,
## #   ²​cityname, ³​geographiclevel, ⁴​datasource, ⁵​category, ⁶​datavaluetypeid
summary(df) #summarizing the dataset
##       year       stateabbr          statedesc            region         
##  Min.   :2016   Length:787255      Length:787255      Length:787255     
##  1st Qu.:2016   Class :character   Class :character   Class :character  
##  Median :2017   Mode  :character   Mode  :character   Mode  :character  
##  Mean   :2017                                                           
##  3rd Qu.:2017                                                           
##  Max.   :2017                                                           
##    cityname         geographiclevel     datasource          category        
##  Length:787255      Length:787255      Length:787255      Length:787255     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##    measure          datavaluetypeid    data_value_type      data_value  
##  Length:787255      Length:787255      Length:787255      Min.   : 0.3  
##  Class :character   Class :character   Class :character   1st Qu.:10.0  
##  Mode  :character   Mode  :character   Mode  :character   Median :23.0  
##                                                           Mean   :31.4  
##                                                           3rd Qu.:46.0  
##                                                           Max.   :95.7  
##  populationcount    categoryid         measureid         short_question_text
##  Min.   :     50   Length:787255      Length:787255      Length:787255      
##  1st Qu.:   2499   Class :character   Class :character   Class :character   
##  Median :   3694   Mode  :character   Mode  :character   Mode  :character   
##  Mean   :  10958                                                            
##  3rd Qu.:   5078                                                            
##  Max.   :8175133
dim(df) #checking the dimensions of the data frame
## [1] 787255     16
colSums(is.na(df)) #checking if there are any missing values
##                year           stateabbr           statedesc              region 
##                   0                   0                   0                   0 
##            cityname     geographiclevel          datasource            category 
##                   0                   0                   0                   0 
##             measure     datavaluetypeid     data_value_type          data_value 
##                   0                   0                   0                   0 
##     populationcount          categoryid           measureid short_question_text 
##                   0                   0                   0                   0
table(df$datavaluetypeid)
## 
## AgeAdjPrv    CrdPrv 
##     13953    773302

The dataset has 787255 rows, 16 columns, and no missing values. There are more data values presented as crude prevalence, so the project will use these values instead of the age-adjusted prevalence.

Selecting crude prevalence, year and categories for states bordering Kansas

df2<- df|>
  filter(datavaluetypeid=="CrdPrv" & stateabbr %in% c("KS", "CO", "MO", "OK", "NE") & year=="2017")

Creating boxplots of the three categories for Kansas and its neighbors

ggplot(data = df2, aes(x = statedesc, y = data_value, color=statedesc)) +
  geom_boxplot()+
    facet_wrap(~factor(category, levels = c("Unhealthy Behaviors", "Health Outcomes", "Prevention")),nrow=2)+
  scale_color_brewer(palette = "Set2")+
  theme_light()+
  theme(axis.text.x = element_text(angle = 45, hjust=1))

The boxplots seem to show that the prevalence of unhealthy behaviors, health outcomes and prevention mentions in Kansas appears to be roughly the same with Missouri, Nebraska, and Oklahoma. The prevalence in all three categories appears lowest in Colorado. This is interesting; however, it would be better to examine geographic levels that have some similarities and also look at specific measures. Let’s take a closer look at Kansas.

An In-depth look at Kansas and select risk factors for heart disease

Heart disease is the leading cause of death in the US and the selected measures are some of the common risk factors for heart disease.

df3<- df|>
  filter(datavaluetypeid=="CrdPrv" & stateabbr=="KS" & year=="2017" & measureid %in% c("BPHIGH", "HIGHCHOL", "OBESITY", "CSMOKING"))

Visualizing risk factors for heart disease in Kansas

ggplot(data = df3, aes(x = cityname, y = data_value, color=cityname)) +
  geom_boxplot()+
  facet_wrap(~factor(short_question_text, levels = c("Obesity", "High Blood Pressure", "High Cholesterol","Current Smoking")),nrow=2)+
  scale_color_brewer(palette = "Set2")+
  theme_light()+
  theme(axis.text.x = element_text(angle = 45, hjust=1))

The boxplot above suggests that among the six cities in Kansas, Kansas City has the highest prevalence of obesity, high blood pressure, high cholesterol, and smoking . However, the boxplot combines all geographical levels - census tracts and cities. Since there is no additional information to distinguish between the census tracts, we will look only at the cities.

Selecting crude prevalence rates for the four risk factors for health disease for the 6 cities in Kansas.

df4<- df|>
  filter(datavaluetypeid=="CrdPrv" & stateabbr=="KS" & year=="2017" & geographiclevel=="City" & measureid %in% c("BPHIGH", "HIGHCHOL", "OBESITY", "CSMOKING"))

Calculating the mean crude prevalence of the four risk factors for heart disease across all cities in the 500 cities dataset

df5<-df|>
   filter(datavaluetypeid=="CrdPrv" & year=="2017" & geographiclevel=="City" & measureid %in% c("BPHIGH", "HIGHCHOL", "OBESITY", "CSMOKING"))|>
  group_by(measureid)|>
  summarise(avgdatavalue=mean(data_value))|>
ungroup()
print(df5)
## # A tibble: 4 × 2
##   measureid avgdatavalue
##   <chr>            <dbl>
## 1 BPHIGH            29.6
## 2 CSMOKING          17.2
## 3 HIGHCHOL          31.3
## 4 OBESITY           29.7

Final Visualization: Plotting the crude prevelance for four risk factors for heart disease across the six Kansas cities in the dataset

ggplot(data=df4, aes(x=cityname, y=data_value, fill=cityname)) +
    geom_bar(stat = "identity") +
        labs(x= "City Name",
             y = "Crude Prevalence (%)",
             title = "Prevalence of Four Heart Disease Risk Factors in Six Kansas Cities",
             caption = "Source: Centers for Disease Control and Prevention (CDC)")+
  scale_fill_brewer(name= "City Name", palette = "Dark2")+
  geom_text(aes(label=paste(data_value,"%", sep="")), size=3,hjust=.5, vjust=2.5, color="white") +
   facet_wrap(~factor(short_question_text, levels = c("Obesity", "High Blood Pressure", "High Cholesterol","Current Smoking")),nrow=2)+
  theme_bw()+
  theme(legend.position="top", legend.title = element_text(size=10), legend.key.size = unit(2, 'mm'), axis.text.x = element_text(angle = 45, hjust=1))

Essay

The 500 cities dataset used for this project is a relatively clean data set. Additional cleaning included recoding the column headers to lower case as well as recoding to remove the spaces between the column header names.

The final visualization shows the prevalence of four risk factors for heart disease among six cities in Kansas. The four risk factors are high blood pressure, obesity, and current smoking among adults age 18 and older at the time of the survey as well as high cholesterol among adults age 18 years and older who have been screened within the past 5 years of the survey. For each of the measures, information about gender, race, and/or socio-economic factors would have been useful for a more meaningful comparison and interpretation of the results as these are also deeply intertwined with health access and outcomes. The final visualization shows that the prevalence of obesity, high blood pressure and smoking is highest in Kansas City, while the prevalence of high cholesterol is highest in Topeka. It is not surprising that the prevalence for all risk factors is higher in Kansas City, Topeka, and Wichita as compared with the prevalence of these risk factors in Lawrence, Olathe, and Overland Park. Lawrence, Olathe and Overland Park have the lowest prevalence for the measure on lack of access to health insurance which can be associated with three of the health outcomes shown in this visualization. At 17.6%, the prevalence of smoking among adults in Lawrence seems high.

One addition that I was unable to include was a horizontal line showing the average prevalence across all the cities in the dataset for each measure.