This is my case study project for the Google Data Analytics Course. I have put this case study together in R Markdown to help illustrate my process and the code all in a single location.
Soon to be Retirees - This is the main audience as I am hoping to raise awareness for this audience before it’s to late. I would be targeting people in their 40’s and 50’s.
Family of Retirees - The cost of healthcare may be shouldered by the retiree’s family and making sure they are aware of the discrepancy in average cost vs how much they may have saved up is a key objective.
The Broader Public Audience - I think this is an issue that needs to have more awareness broadly before you even get close to retirement age. This would help people plan more effectively when they are still early on in their careers.
FOR POPULATION & AGE - I will be using the Colorado Population dataset all the pop estimates since 1990. Colorado.gov Population Estimate from 1990 to 2050
FOR INCOME - I will use the ACS Median Income in the Past 12 Months by age shows income by 45-65 range and 65 and over ACS Median Income in the Past 12 Months by age for 2022) - I ended up using the TidyCensus package and calling the data directly from the Census API.
FOR HEALTHCARE COST - I will be using the gathered data from a Private Org and needs to be added to table - National & State Data Tables (pdf)
chooseCRANmirror(graphics=FALSE, ind=1)
knitr::opts_chunk$set(echo = TRUE)
install.packages("tidyverse")##
## The downloaded binary packages are in
## /var/folders/1v/dl3wj8hj7_qdscktqmzf7w5w0000gn/T//RtmpcpcUYb/downloaded_packages
##
## The downloaded binary packages are in
## /var/folders/1v/dl3wj8hj7_qdscktqmzf7w5w0000gn/T//RtmpcpcUYb/downloaded_packages
##
## The downloaded binary packages are in
## /var/folders/1v/dl3wj8hj7_qdscktqmzf7w5w0000gn/T//RtmpcpcUYb/downloaded_packages
## Warning: package 'dyplr' is not available for this version of R
##
## A version of this package for your version of R might be available elsewhere,
## see the ideas at
## https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
##
## The downloaded binary packages are in
## /var/folders/1v/dl3wj8hj7_qdscktqmzf7w5w0000gn/T//RtmpcpcUYb/downloaded_packages
##
## The downloaded binary packages are in
## /var/folders/1v/dl3wj8hj7_qdscktqmzf7w5w0000gn/T//RtmpcpcUYb/downloaded_packages
##
## The downloaded binary packages are in
## /var/folders/1v/dl3wj8hj7_qdscktqmzf7w5w0000gn/T//RtmpcpcUYb/downloaded_packages
##
## The downloaded binary packages are in
## /var/folders/1v/dl3wj8hj7_qdscktqmzf7w5w0000gn/T//RtmpcpcUYb/downloaded_packages
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
##
## Attaching package: 'janitor'
##
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
library(lubridate)
census_api_key("899595acd1a9b3289bb259cd44cd94252835f372", install = TRUE , overwrite=TRUE)## Your original .Renviron will be backed up and stored in your R HOME directory if needed.
## Your API key has been stored in your .Renviron and can be accessed by Sys.getenv("CENSUS_API_KEY").
## To use now, restart R or run `readRenviron("~/.Renviron")`
## [1] "899595acd1a9b3289bb259cd44cd94252835f372"
In order for me to find and pull the correct data from the census database I need to load the variable codes into a viewable dataframe
Pulling out all of the census data per state for over 65 population. - Rows are grouped by income bracket - I called each one individually and created legible aliases for them
Incomebystate2022_RAW <- get_acs(
geography = "state",
variables = c(totalOver65 = "B19037_053E",
e01_lessthan10k = "B19037_054E",
e02_10kto14k = "B19037_055E",
e03_15kto19k = "B19037_056E",
e04_20kto24k = "B19037_057E",
e05_25kto29k = "B19037_058E",
e06_30kto34k = "B19037_059E",
e07_35kto39k = "B19037_060E",
e08_40kto44k = "B19037_061E",
e09_45kto49k = "B19037_062E",
e10_50kto54k = "B19037_063E",
e11_55kto59k = "B19037_064E",
e12_60kto74k = "B19037_065E",
e13_75kto99k = "B19037_066E",
e14_100kto124k = "B19037_067E",
e15_125kto149k = "B19037_068E",
e16_200Kplus = "B19037_069E"),
output = "wide",
year = 2022
)## Getting data from the 2018-2022 5-year ACS
Now i need to remove the Margin of error columns that have the suffix M and rename columns
I need to reformat the data in order to visualize it better in a longer format
After looking at the data we can see that - Yearly Income for 65+ in colorado is mostly in the 60K to $74K Region - Healthcare costs are $116,709 for a private room - That means that people are coming up short by $42,709