NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship ๐Ÿ† Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lesson
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular ๐Ÿ”ฅ Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New ๐ŸŽ‰ Generative AI for Finance New ๐ŸŽ‰ Generative AI for Marketing New ๐ŸŽ‰
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular ๐Ÿ”ฅ Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular ๐Ÿ”ฅ Data Science R: Machine Learning Designing and Implementing Production MLOps New ๐ŸŽ‰ Natural Language Processing for Production (NLP) New ๐ŸŽ‰
Find Inspiration
Get Course Recommendation Must Try ๐Ÿ’Ž An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lessons
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > R > Diabetes, Obesity, and Income

Diabetes, Obesity, and Income

William Aiken
Posted on Nov 18, 2015

Contributed by William Aiken. William took NYC Data Science Academy 12 week full time Data Science Bootcamp program between Sept 23 to Dec 18, 2015. The post was based on his second class project(due at 4th week of the program).

This was my first data science project associated with the bootcamp.  The goal of this project was a visualization and explorations of New York state diabetic incidence data.  I wanted to look at data sets where there existed previously established relationships.  I chose a public health issue of diabetic rates and obesity, it has been shown that there is a strong link between these two issues.  I thought it would be of interest to see how this relationship played out in New York state.  The data used were part of the 1,250 freely available data sets on the ny.gov website, an amazing resource for public health issues.  Four different sets were utilized: an income data set; a diabetic rate set; a diabetic mortality rate and an obesity rate data set(all from 2009).  All of these data sets provided granularity at the  county level.  The inclusion of the last three data sets are very straight forward.  Income data was included in this analysis for two reasons, first there is a long established relationship between income and diabetic rates.  Secondly, New York is the only state where the poorest county(Bronx) is directly adjacent to the most affluent county(Manhattan/New York County).  I was curious to see what relationships existed alongside this economic disparity.  New York state contains fifty-two counties so I wanted to find a way to represent this data that made comparisons between counties easy and also retained spacial relations.   Choropleth maps were ideal for this task.  These maps use color intensity to represent aggregated data within a geographic region, either intensive or extensive.  Luckily for me, the R programming language had several libraries to aid in this mapping, choroplethR had the shallowest learning curve.  Rather than just bury the reader in plots, I will present only the most interesting plots in the post.  But here is a link to a Shiny application that I created that will allow you to explore with all the data.  Shiny App

Before my data could be mapped with choroplethR library it required some manipulation.  Thankfully the data was complete, if anything there was more data than I required.  Several of the data sets contained information years beyond 2009, my year of interest.  Some data sets included aggregations of regions that required exclusion.  Lastly all of the data sets contained formating that required adjusting so they joined with the FIPs dataset required by choroplethR.  

Here is the code for the for my loading and data munging.

library(choroplethr)
library(choroplethrMaps)
library(dplyr)
library(ggplot2)
data("county.regions")

Income <- read.csv("AverageIncome.csv",stringsAsFactors = FALSE)
Mortality <- read.csv("Mortality2009-2011.csv",stringsAsFactors = FALSE)
Obese <- read.csv("Obese08-09.csv",stringsAsFactors = FALSE)
Diagnosed <- read.csv("Diagnosed.csv",stringsAsFactors = FALSE)

Diagnosed <- rename(Diagnosed, County = County.Name)
Income <- rename(Income, County = Place.of.Residence)
Obese <- rename(Obese, County = County.Name)
Mortality <- rename(Mortality, County = County.Name)
Income$County <- as.character(Income$County)


Income <-mutate(Income, County=ifelse(County=="New York City - Bronx", "Bronx", County))
Income <-mutate(Income, County=ifelse(County=="New York City - Kings", "Kings", County))
Income <-mutate(Income, County=ifelse(County=="New York City - Manhattan", "New York", County))
Income <-mutate(Income, County=ifelse(County=="New York City - Queens", "Queens", County))
Income <-mutate(Income, County=ifelse(County=="New York City - Richmond", "Richmond", County))


Income09 <- filter(Income, Tax.Year %in% 2009)
Income09 <- mutate(Income09, County = ifelse(County == "new york city", "new york", County))


Obese$County <- tolower(Obese$County)
Income$County <- tolower(Income$County)
Mortality$County <- tolower(Mortality$County)
Diagnosed$County <- tolower(Diagnosed$County)


DiaDiagnosed <- filter(Diagnosed, Diagnosed$Health.Topic %in% "Cirrhosis/Diabetes Indicators")


DiaDiagnosed <- rename(DiaDiagnosed, value = Percent.Rate)
Mortality <- rename(Mortality, value = Percentage.Rate)
Income09 <- rename(Income09, value = Average.NY.AGI.of.All.Returns)
Obese <- rename(Obese, value = Percentage.Rate)


Test <- filter(county.region, state.name %in% "new york")


Test2 <- left_join(Test, Obese, by = c("county.name" = "County"))
Test3 <- left_join(Test, Income09, by = c("county.name" = "County"))
Test4 <- left_join(Test, DiaDiagnosed, by = c("county.name" = "County"))
Test5 <- left_join(Test, Mortality, by = c("county.name" = "County"))

 

Here is the choropleth map of diabetic rates for all the counties in New York state in 2009.  The values represent all the percent of the population that has been diagnosed by a doctor as being diabetic.

 

New York Diabetic Rates

Here is a choropleth map of all the average incomes within the five New York City counties.  The disparity between Manhattan and the other four counties is striking.NYC Average Income

 

 

After the data sets had been joined to the FIPs county data set they could be visualized with choroplethR.  The code for the plots is listed here.

county_choropleth(Test2,
                 title      = "2009 New York State Obesity Rates",
                 legend     = "% Population Obese",
                 num_colors = 1,
                 state_zoom = c("new york"))
                 
new_york_city = c(36005, 36047, 36061, 36081, 36085)
county_choropleth(Test2,
                   title       = "2009 New York City Obesity Rates",
                   legend      = "% Population Obese",
                   num_colors  = 1,
                   county_zoom = new_york_city)

county_choropleth(Test3,
                   title      = "2009 Average Incomes by County",
                   legend     = "Average Income in Thousands of $",
                   num_colors = 9,
                   state_zoom = c("new york")) + scale_fill_brewer(palette=2)
                   
new_york_city = c(36005, 36047, 36061, 36081, 36085)
county_choropleth(Test3,
                   title       = "2009 Average Income",
                   legend      = "Income in Thousands",
                   num_colors  = 9,
                   county_zoom = new_york_city)+scale_fill_brewer(palette=2)

county_choropleth(Test4,
                   title      = "Diabetic Rates per County",
                   legend     = "Percent of population with Diabetes",
                   num_colors = 9,
                   state_zoom = c("new york")) + scale_fill_brewer(palette=3)
                   
new_york_city = c(36005, 36047, 36061, 36081, 36085)
county_choropleth(Test4,
                   title       = "Diabetic Rates per County",
                   legend      = "Percent of population with Diabetes",
                   num_colors  = 9,
                   county_zoom = new_york_city)+scale_fill_brewer(palette=3)

county_choropleth(Test5,
                   title      = "Diabetic Deaths per County 2009-2011",
                   legend     = "Percent of Deaths Caused by Diabetes",
                   num_colors = 9,
                   state_zoom = c("new york")) + scale_fill_brewer(palette=4)
                   
new_york_city = c(36005, 36047, 36061, 36081, 36085)
county_choropleth(Test4,
                   title       = "Percent of Diabetic Deaths per County",
                   legend      = "Percent of Deaths Caused by Diabetes",
                   num_colors  = 9,
                   county_zoom = new_york_city)+scale_fill_brewer(palette=4)

 

Here is a scatterplot exploring the relationship between the diabetic rates for each county and their corresponding obesity rate.  It's worth noting that this data is inherently normalized  due of it's ratio nature (incidence per 100,000 residents).Income vs Diabetic Rate

 

The data was also plotted in scatterplots to better visualize some of the non-spacial relationships within the data sets.  The code for the scatterplots is listed below.

qplot(Test3$value, Test4$value, xlab = "Income in Thousands", ylab = "Percent Diabetic",
 main = "Average Income vs Diabetic Rate in New York Counties") + (geom_smooth())

qplot(Test3$value, Test5$value, xlab = "Income in Thousands", ylab = "Percent of Deaths attributed to Diabetes",
 main = "Average Income vs Diabetic Mortality Rate in New York Counties") + (geom_smooth())

qplot(Test3$value, Test2$value, xlab = "Income in Thousands", ylab = "Percent Obese",main = "Average Income vs Obese Rate in New York Counties") +
(geom_smooth())

qplot(Test4$value, Test2$value, xlab = "Percent Diabetic", ylab = "Percent Obese",main = "Percent Diabetic vs Percent Obese") +
(geom_smooth())

 

Conclusion:

The data substantiated the already established relationships between income, obesity and diabetes.  Counties with the highest average incomes had the lowest incidence of diabetes.  The link between obesity and diabetes was also shown.  Interestingly, counties with high incomes and high obesity rates had low rates of diabetes.  The link between income and diabetes may be as strong as the relationship between diabetes and obesity.  I haven't included my Shiny app code for the sake of space put it can be found on my Github here.My Github

 

About Author

William Aiken

Nate Aiken graduated from City College in 2014 with a BS in Biology with a focus in Neuroscience. His experience studying vision and hearing in labs at City and Rockefeller University led him to the bootcamp. He enjoys...
View all posts by William Aiken >

Leave a Comment

Cancel reply

You must be logged in to post a comment.

Google September 2, 2020
Google The time to read or pay a visit to the material or web pages we have linked to beneath.
Lorenzo Sร nchez Mรจndez March 14, 2017
Hi William Aiken, I`m Lorenzo Sร nchez from Mexico. I`ve read your post and your application is very interesting. I will start to develop a data science application for diabetes mellitus E11 and E14, and I would like that you may explain me more about the process you followed, since the beginning to the end. Did you write a paper? if so, could you send it me ? This, in order to cite you thanks for your attention, I will be waiting for the answer My email: lorenzosanchez16c@cenidet.edu.mx Lorenzo Sร nchez Mรจndez
boucles d'oreilles Van Cleef & Arpels replique September 20, 2016
cartierbraceletlove muy buenas, el 19-07-2015 me dieron un golpe por detrรกs, actual mente sigo de baja y con dolor en cervicales ( no puedo mover muy bien el cuello) soy autรณnomo y me gustarรญa saber si hubiera alguna manera de saber si los autรณnomos como trabajador por tu cuenta indemnizan mas cantidad o no, ya que estoy en una situaciรณn un poco extrema y me tengo que poner a trabajar ya mismo para poder llegar a fin de mes y puedo hasta perder mi trabajo, estarรญa muy interesado en que me pudieran orientar,muchas gracias de antemano. boucles d'oreilles Van Cleef & Arpels replique http://www.bijouxclassique.net/replica-van-cleef-earrings-c3_90.html
bijoux van cleef and arpels 10 motif prix August 18, 2016
http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-white-mother-of-pearl-vcara42100-p217.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-ring-carnelian-vcard40800-p332.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-ring-diamond-vcara40900-p333.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-ring-diamond-vcarf48900-p334.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-ring-onyx-vcara41000-p335.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-earclips-carnelian-vcard40400-p306.html http://www.vancleefalhambra.com/cheap-sweet-alhambra-earstuds-heart-carnelian-vcarn6bp00-p305.html http://www.vancleefalhambra.com/cheap-sweet-alhambra-earstuds-clover-carnelian-vcarn6bo00-p304.html http://www.vancleefalhambra.com/cheap-sweet-alhambra-earstuds-butterfly-white-mother-of-pearl-vcarn5jm00-p303.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-necklace-10-motifs-yellow-gold-vcara42800-p220.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-vcara43100-p221.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-earclips-turquoise-vcarb84100-p309.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-earclips-turquoise-vcara44400-p308.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-necklace-10-motifs-vcaro3qj00-p230.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-malachite-vcarl88100-p229.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-white-mother-of-pearl-vcarf48800-p228.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-necklace-10-motifs-vcarf48500-p227.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-necklace-10-motifs-vcard40600-p226.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-carnelian-vcard39800-p225.html bijoux van cleef and arpels 10 motif prix http://www.meilleurbijoux.ru/
van cleef & arpels necklace August 3, 2016
cartierbraceletlove Por lo que comentas si que es compatible. Tienes que tener en cuenta que tambiรฉn entra en juego la calidad de fabricaciรณn, si el telรฉfono es de marca dudosa, es muy comรบn los problemas que comentas. Un saludo. van cleef & arpels necklace http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-yellow-gold-vcara43200-p222.html
เนเธซเธฅเนˆเธ‡เธ‚เธฒเธขเธ—เธตเนˆเธ™เธญเธ™เธฃเธฒเธ„เธฒเธ–เธนเธ April 3, 2016
I don't even know how I finished up right here, however I believed this put up used to be great. I do not understand who you are however certainly you are going to a well-known blogger in case you aren't already. Cheers!
occasion auto March 17, 2016
I am in fact delighted to glance at this webpage posts which contains plenty of helpful facts, thanks for providing such statistics.
pinoy movies March 12, 2016
I really like what you guys tend to be up too. This type of clever work and reporting! Keep up the terrific works guys I've you guys to blogroll.
Hadlow Village Hall is set in the beautiful Kent countryside, and offers a great venue for your Club, Activity or Event. February 15, 2016
I take pleasure in, cause I found exactly what I used to be looking for. You've ended my 4 day lengthy hunt! God Bless you man. Have a nice day. Bye
anavar December 27, 2015
The 2 sites are undoubtedly listed over the complete of this amazing article. If that being said then you will may have Gram-Negative Folliculitis. Overcome to build started at this time.

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    ยฉ 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application