getwd()
## [1] "C:/Users/Jerome/Documents/0000_Work_Files/0000_Coursera/Statistics_with_R_Specialization/Course_1_Probability_&_Data/Week_5_Project"
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(statsr)
## Warning: package 'statsr' was built under R version 4.0.3
load("brfss2013.RData")

This table was run just for fun, as a test of the database.

table(brfss2013$bpmeds, brfss2013$genhlth)
##      
##       Excellent Very good  Good  Fair  Poor
##   Yes     11889     42555 59353 35138 16404
##   No       3921      9635 10929  5492  2289

According to the website MDEDGE, https://www.mdedge.com/chestphysician/article/79880/health-policy/hawaii-named-healthiest-state-2013, accessed 6 August 2021, Hawaii had the healthiest population in the USA in 2013; Mississippi had the lowest ranking, 50/50. The same rankings held in 2020; https://www.beckershospitalreview.com/rankings-and-ratings/50-states-ranked-from-healthiest-to-unhealthiest.html. For purposes of this exercise, I want to compare various indicators for these 2 states to see the extent of the differences between them.

Filter the dataset to create a dataset of only Hawaii and Mississippi

 hims6 <- subset(brfss2013, brfss2013$X_state == "Hawaii" | brfss2013$X_state == "Mississippi")
write.csv(hims6, "hims6.csv", row.names = FALSE)