library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.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
library(readxl)
tx_counties<-read_excel("tx.counties.xlsx", sheet = "Select Measure Data", skip = 1)
## New names:
## • `Unreliable` -> `Unreliable...4`
## • `95% CI - Low` -> `95% CI - Low...7`
## • `95% CI - High` -> `95% CI - High...8`
## • `National Z-Score` -> `National Z-Score...9`
## • `95% CI - Low` -> `95% CI - Low...39`
## • `95% CI - High` -> `95% CI - High...40`
## • `National Z-Score` -> `National Z-Score...41`
## • `Unreliable` -> `Unreliable...42`
## • `95% CI - Low` -> `95% CI - Low...44`
## • `95% CI - High` -> `95% CI - High...45`
## • `National Z-Score` -> `National Z-Score...46`
## • `95% CI - Low` -> `95% CI - Low...69`
## • `95% CI - High` -> `95% CI - High...70`
## • `National Z-Score` -> `National Z-Score...71`
## • `95% CI - Low` -> `95% CI - Low...73`
## • `95% CI - High` -> `95% CI - High...74`
## • `National Z-Score` -> `National Z-Score...75`
## • `National Z-Score` -> `National Z-Score...77`
## • `National Z-Score` -> `National Z-Score...84`
## • `National Z-Score` -> `National Z-Score...86`
## • `National Z-Score` -> `National Z-Score...90`
## • `National Z-Score` -> `National Z-Score...94`
## • `National Z-Score` -> `National Z-Score...98`
## • `National Z-Score` -> `National Z-Score...100`
## • `National Z-Score` -> `National Z-Score...107`
## • `95% CI - Low` -> `95% CI - Low...115`
## • `95% CI - High` -> `95% CI - High...116`
## • `National Z-Score` -> `National Z-Score...117`
## • `95% CI - Low` -> `95% CI - Low...119`
## • `95% CI - High` -> `95% CI - High...120`
## • `National Z-Score` -> `National Z-Score...130`
## • `95% CI - Low` -> `95% CI - Low...132`
## • `95% CI - High` -> `95% CI - High...133`
## • `National Z-Score` -> `National Z-Score...134`
## • `95% CI - Low` -> `95% CI - Low...152`
## • `95% CI - High` -> `95% CI - High...153`
## • `National Z-Score` -> `National Z-Score...154`
## • `National Z-Score` -> `National Z-Score...156`
## • `National Z-Score` -> `National Z-Score...158`
## • `95% CI - Low` -> `95% CI - Low...161`
## • `95% CI - High` -> `95% CI - High...162`
## • `National Z-Score` -> `National Z-Score...163`
## • `National Z-Score` -> `National Z-Score...165`
## • `Population` -> `Population...167`
## • `95% CI - Low` -> `95% CI - Low...169`
## • `95% CI - High` -> `95% CI - High...170`
## • `National Z-Score` -> `National Z-Score...171`
## • `Population` -> `Population...173`
## • `95% CI - Low` -> `95% CI - Low...175`
## • `95% CI - High` -> `95% CI - High...176`
## • `National Z-Score` -> `National Z-Score...177`
## • `National Z-Score` -> `National Z-Score...181`
## • `National Z-Score` -> `National Z-Score...185`
## • `95% CI - Low` -> `95% CI - Low...187`
## • `95% CI - High` -> `95% CI - High...188`
## • `National Z-Score` -> `National Z-Score...189`
## • `95% CI - Low` -> `95% CI - Low...197`
## • `95% CI - High` -> `95% CI - High...198`
## • `National Z-Score` -> `National Z-Score...199`
## • `National Z-Score` -> `National Z-Score...223`
## • `National Z-Score` -> `National Z-Score...225`
view(tx_counties)
names(tx_counties)
## [1] "FIPS"
## [2] "State"
## [3] "County"
## [4] "Unreliable...4"
## [5] "Deaths"
## [6] "Years of Potential Life Lost Rate"
## [7] "95% CI - Low...7"
## [8] "95% CI - High...8"
## [9] "National Z-Score...9"
## [10] "YPLL Rate (Hispanic (all races))"
## [11] "YPLL Rate (Hispanic (all races)) 95% CI - Low"
## [12] "YPLL Rate (Hispanic (all races)) 95% CI - High"
## [13] "YPLL Rate (Hispanic (all races)) Unreliable"
## [14] "YPLL Rate (Non-Hispanic AIAN)"
## [15] "YPLL Rate (Non-Hispanic AIAN) 95% CI - Low"
## [16] "YPLL Rate (Non-Hispanic AIAN) 95% CI - High"
## [17] "YPLL Rate (Non-Hispanic AIAN) Unreliable"
## [18] "YPLL Rate (Non-Hispanic Asian)"
## [19] "YPLL Rate (Non-Hispanic Asian) 95% CI - Low"
## [20] "YPLL Rate (Non-Hispanic Asian) 95% CI - High"
## [21] "YPLL Rate (Non-Hispanic Asian) Unreliable"
## [22] "YPLL Rate (Non-Hispanic Black)"
## [23] "YPLL Rate (Non-Hispanic Black) 95% CI - Low"
## [24] "YPLL Rate (Non-Hispanic Black) 95% CI - High"
## [25] "YPLL Rate (Non-Hispanic Black) Unreliable"
## [26] "YPLL Rate (Non-Hispanic Native Hawaiian and Other Pacific Islander)"
## [27] "YPLL Rate (Non-Hispanic Native Hawaiian and Other Pacific Islander) 95% CI - Low"
## [28] "YPLL Rate (Non-Hispanic Native Hawaiian and Other Pacific Islander) 95% CI - High"
## [29] "YPLL Rate (Non-Hispanic Native Hawaiian and Other Pacific Islander) Unreliable"
## [30] "YPLL Rate (Non-Hispanic 2+ races)"
## [31] "YPLL Rate (Non-Hispanic 2+ races) 95% CI - Low"
## [32] "YPLL Rate (Non-Hispanic 2+ races) 95% CI - High"
## [33] "YPLL Rate (Non-Hispanic 2+ races) Unreliable"
## [34] "YPLL Rate (Non-Hispanic White)"
## [35] "YPLL Rate (Non-Hispanic White) 95% CI - Low"
## [36] "YPLL Rate (Non-Hispanic White) 95% CI - High"
## [37] "YPLL Rate (Non-Hispanic White) Unreliable"
## [38] "Average Number of Physically Unhealthy Days"
## [39] "95% CI - Low...39"
## [40] "95% CI - High...40"
## [41] "National Z-Score...41"
## [42] "Unreliable...42"
## [43] "% Low Birth Weight"
## [44] "95% CI - Low...44"
## [45] "95% CI - High...45"
## [46] "National Z-Score...46"
## [47] "% LBW (Hispanic (all races))"
## [48] "% LBW (Hispanic (all races)) 95% CI - Low"
## [49] "% LBW (Hispanic (all races)) 95% CI - High"
## [50] "% LBW (Non-Hispanic AIAN)"
## [51] "% LBW (Non-Hispanic AIAN) 95% CI - Low"
## [52] "% LBW (Non-Hispanic AIAN) 95% CI - High"
## [53] "% LBW (Non-Hispanic Asian)"
## [54] "% LBW (Non-Hispanic Asian) 95% CI - Low"
## [55] "% LBW (Non-Hispanic Asian) 95% CI - High"
## [56] "% LBW (Non-Hispanic Black)"
## [57] "% LBW (Non-Hispanic Black) 95% CI - Low"
## [58] "% LBW (Non-Hispanic Black) 95% CI - High"
## [59] "% LBW (Non-Hispanic Native Hawaiian and Other Pacific Islander)"
## [60] "% LBW (Non-Hispanic Native Hawaiian and Other Pacific Islander) 95% CI - Low"
## [61] "% LBW (Non-Hispanic Native Hawaiian and Other Pacific Islander) 95% CI - High"
## [62] "% LBW (Non-Hispanic 2+ races)"
## [63] "% LBW (Non-Hispanic 2+ races) 95% CI - Low"
## [64] "% LBW (Non-Hispanic 2+ races) 95% CI - High"
## [65] "% LBW (Non-Hispanic White)"
## [66] "% LBW (Non-Hispanic White) 95% CI - Low"
## [67] "% LBW (Non-Hispanic White) 95% CI - High"
## [68] "Average Number of Mentally Unhealthy Days"
## [69] "95% CI - Low...69"
## [70] "95% CI - High...70"
## [71] "National Z-Score...71"
## [72] "% Fair or Poor Health"
## [73] "95% CI - Low...73"
## [74] "95% CI - High...74"
## [75] "National Z-Score...75"
## [76] "% Vaccinated"
## [77] "National Z-Score...77"
## [78] "% Vaccinated (AIAN)"
## [79] "% Vaccinated (Asian)"
## [80] "% Vaccinated (Black)"
## [81] "% Vaccinated (Hispanic)"
## [82] "% Vaccinated (White)"
## [83] "% With Access to Exercise Opportunities"
## [84] "National Z-Score...84"
## [85] "Food Environment Index"
## [86] "National Z-Score...86"
## [87] "# Primary Care Physicians"
## [88] "Primary Care Physicians Rate"
## [89] "Primary Care Physicians Ratio"
## [90] "National Z-Score...90"
## [91] "# Mental Health Providers"
## [92] "Mental Health Provider Rate"
## [93] "Mental Health Provider Ratio"
## [94] "National Z-Score...94"
## [95] "# Dentists"
## [96] "Dentist Rate"
## [97] "Dentist Ratio"
## [98] "National Z-Score...98"
## [99] "Preventable Hospitalization Rate"
## [100] "National Z-Score...100"
## [101] "Preventable Hosp. Rate (AIAN)"
## [102] "Preventable Hosp. Rate (Asian)"
## [103] "Preventable Hosp. Rate (Black)"
## [104] "Preventable Hosp. Rate (Hispanic)"
## [105] "Preventable Hosp. Rate (White)"
## [106] "% with Annual Mammogram"
## [107] "National Z-Score...107"
## [108] "% Screened (AIAN)"
## [109] "% Screened (Asian)"
## [110] "% Screened (Black)"
## [111] "% Screened (Hispanic)"
## [112] "% Screened (White)"
## [113] "# Uninsured"
## [114] "% Uninsured"
## [115] "95% CI - Low...115"
## [116] "95% CI - High...116"
## [117] "National Z-Score...117"
## [118] "% Severe Housing Problems"
## [119] "95% CI - Low...119"
## [120] "95% CI - High...120"
## [121] "Severe Housing Cost Burden"
## [122] "Severe Housing Cost Burden 95% CI - Low"
## [123] "Severe Housing Cost Burden 95% CI - High"
## [124] "Overcrowding"
## [125] "Overcrowding 95% CI - Low"
## [126] "Overcrowding 95% CI - High"
## [127] "Inadequate Facilities"
## [128] "Inadequate Facilities 95% CI - Low"
## [129] "Inadequate Facilities 95% CI - High"
## [130] "National Z-Score...130"
## [131] "% Drive Alone to Work"
## [132] "95% CI - Low...132"
## [133] "95% CI - High...133"
## [134] "National Z-Score...134"
## [135] "% Drive Alone (AIAN)"
## [136] "% Drive Alone (AIAN) 95% CI - Low"
## [137] "% Drive Alone (AIAN) 95% CI - High"
## [138] "% Drive Alone (Asian)"
## [139] "% Drive Alone (Asian) 95% CI - Low"
## [140] "% Drive Alone (Asian) 95% CI - High"
## [141] "% Drive Alone (Black)"
## [142] "% Drive Alone (Black) 95% CI - Low"
## [143] "% Drive Alone (Black) 95% CI - High"
## [144] "% Drive Alone (Hispanic)"
## [145] "% Drive Alone (Hispanic) 95% CI - Low"
## [146] "% Drive Alone (Hispanic) 95% CI - High"
## [147] "% Drive Alone (White)"
## [148] "% Drive Alone (White) 95% CI - Low"
## [149] "% Drive Alone (White) 95% CI - High"
## [150] "# Workers who Drive Alone"
## [151] "% Long Commute - Drives Alone"
## [152] "95% CI - Low...152"
## [153] "95% CI - High...153"
## [154] "National Z-Score...154"
## [155] "Average Daily PM2.5"
## [156] "National Z-Score...156"
## [157] "Presence of Water Violation"
## [158] "National Z-Score...158"
## [159] "% Households with Broadband Access"
## [160] "# Households with Broadband Access"
## [161] "95% CI - Low...161"
## [162] "95% CI - High...162"
## [163] "National Z-Score...163"
## [164] "Visits per service area population"
## [165] "National Z-Score...165"
## [166] "# Some College"
## [167] "Population...167"
## [168] "% Some College"
## [169] "95% CI - Low...169"
## [170] "95% CI - High...170"
## [171] "National Z-Score...171"
## [172] "# Completed High School"
## [173] "Population...173"
## [174] "% Completed High School"
## [175] "95% CI - Low...175"
## [176] "95% CI - High...176"
## [177] "National Z-Score...177"
## [178] "# Unemployed"
## [179] "Labor Force"
## [180] "% Unemployed"
## [181] "National Z-Score...181"
## [182] "80th Percentile Income"
## [183] "20th Percentile Income"
## [184] "Income Ratio"
## [185] "National Z-Score...185"
## [186] "% Children in Poverty"
## [187] "95% CI - Low...187"
## [188] "95% CI - High...188"
## [189] "National Z-Score...189"
## [190] "% Children in Poverty (AIAN)"
## [191] "% Children in Poverty (Asian)"
## [192] "% Children in Poverty (Black)"
## [193] "% Children in Poverty (Hispanic)"
## [194] "% Children in Poverty (White)"
## [195] "# Injury Deaths"
## [196] "Injury Death Rate"
## [197] "95% CI - Low...197"
## [198] "95% CI - High...198"
## [199] "National Z-Score...199"
## [200] "Injury Death Rate (Hispanic (all races))"
## [201] "Injury Death Rate (Hispanic (all races)) 95% CI - Low"
## [202] "Injury Death Rate (Hispanic (all races)) 95% CI - High"
## [203] "Injury Death Rate (Non-Hispanic AIAN)"
## [204] "Injury Death Rate (Non-Hispanic AIAN) 95% CI - Low"
## [205] "Injury Death Rate (Non-Hispanic AIAN) 95% CI - High"
## [206] "Injury Death Rate (Non-Hispanic Asian)"
## [207] "Injury Death Rate (Non-Hispanic Asian) 95% CI - Low"
## [208] "Injury Death Rate (Non-Hispanic Asian) 95% CI - High"
## [209] "Injury Death Rate (Non-Hispanic Black)"
## [210] "Injury Death Rate (Non-Hispanic Black) 95% CI - Low"
## [211] "Injury Death Rate (Non-Hispanic Black) 95% CI - High"
## [212] "Injury Death Rate (Non-Hispanic Native Hawaiian and Other Pacific Islander)"
## [213] "Injury Death Rate (Non-Hispanic Native Hawaiian and Other Pacific Islander) 95% CI - Low"
## [214] "Injury Death Rate (Non-Hispanic Native Hawaiian and Other Pacific Islander) 95% CI - High"
## [215] "Injury Death Rate (Non-Hispanic 2+ races)"
## [216] "Injury Death Rate (Non-Hispanic 2+ races) 95% CI - Low"
## [217] "Injury Death Rate (Non-Hispanic 2+ races) 95% CI - High"
## [218] "Injury Death Rate (Non-Hispanic White)"
## [219] "Injury Death Rate (Non-Hispanic White) 95% CI - Low"
## [220] "Injury Death Rate (Non-Hispanic White) 95% CI - High"
## [221] "# Associations"
## [222] "Social Association Rate"
## [223] "National Z-Score...223"
## [224] "% Household Income Required for Child Care Expenses"
## [225] "National Z-Score...225"
additional_data<-read_excel("tx.counties.xlsx", sheet = "Additional Measure Data", skip = 1)
## New names:
## • `95% CI - Low` -> `95% CI - Low...5`
## • `95% CI - High` -> `95% CI - High...6`
## • `# Deaths` -> `# Deaths...28`
## • `95% CI - Low` -> `95% CI - Low...30`
## • `95% CI - High` -> `95% CI - High...31`
## • `# Deaths` -> `# Deaths...53`
## • `95% CI - Low` -> `95% CI - Low...55`
## • `95% CI - High` -> `95% CI - High...56`
## • `# Deaths` -> `# Deaths...78`
## • `95% CI - Low` -> `95% CI - Low...80`
## • `95% CI - High` -> `95% CI - High...81`
## • `95% CI - Low` -> `95% CI - Low...104`
## • `95% CI - High` -> `95% CI - High...105`
## • `95% CI - Low` -> `95% CI - Low...107`
## • `95% CI - High` -> `95% CI - High...108`
## • `95% CI - Low` -> `95% CI - Low...112`
## • `95% CI - High` -> `95% CI - High...113`
## • `95% CI - Low` -> `95% CI - Low...115`
## • `95% CI - High` -> `95% CI - High...116`
## • `# Deaths` -> `# Deaths...117`
## • `95% CI - Low` -> `95% CI - Low...119`
## • `95% CI - High` -> `95% CI - High...120`
## • `95% CI - Low` -> `95% CI - Low...144`
## • `95% CI - High` -> `95% CI - High...145`
## • `95% CI - Low` -> `95% CI - Low...151`
## • `95% CI - High` -> `95% CI - High...152`
## • `95% CI - Low` -> `95% CI - Low...154`
## • `95% CI - High` -> `95% CI - High...155`
## • `95% CI - Low` -> `95% CI - Low...180`
## • `95% CI - High` -> `95% CI - High...181`
## • `95% CI - Low` -> `95% CI - Low...185`
## • `95% CI - High` -> `95% CI - High...186`
## • `95% CI - Low` -> `95% CI - Low...189`
## • `95% CI - High` -> `95% CI - High...190`
## • `95% CI - Low` -> `95% CI - Low...213`
## • `95% CI - High` -> `95% CI - High...214`
## • `95% CI - Low` -> `95% CI - Low...216`
## • `95% CI - High` -> `95% CI - High...217`
## • `95% CI - Low` -> `95% CI - Low...220`
## • `95% CI - High` -> `95% CI - High...221`
## • `95% CI - Low` -> `95% CI - Low...224`
## • `95% CI - High` -> `95% CI - High...225`
## • `95% CI - Low` -> `95% CI - Low...231`
## • `95% CI - High` -> `95% CI - High...232`
## • `95% CI - Low` -> `95% CI - Low...235`
## • `95% CI - High` -> `95% CI - High...236`
## • `Average Grade Performance` -> `Average Grade Performance...246`
## • `Average Grade Performance (AIAN)` -> `Average Grade Performance
## (AIAN)...247`
## • `Average Grade Performance (Asian)` -> `Average Grade Performance
## (Asian)...248`
## • `Average Grade Performance (Black)` -> `Average Grade Performance
## (Black)...249`
## • `Average Grade Performance (Hispanic)` -> `Average Grade Performance
## (Hispanic)...250`
## • `Average Grade Performance (White)` -> `Average Grade Performance
## (White)...251`
## • `Average Grade Performance` -> `Average Grade Performance...252`
## • `Average Grade Performance (AIAN)` -> `Average Grade Performance
## (AIAN)...253`
## • `Average Grade Performance (Asian)` -> `Average Grade Performance
## (Asian)...254`
## • `Average Grade Performance (Black)` -> `Average Grade Performance
## (Black)...255`
## • `Average Grade Performance (Hispanic)` -> `Average Grade Performance
## (Hispanic)...256`
## • `Average Grade Performance (White)` -> `Average Grade Performance
## (White)...257`
## • `Segregation Index` -> `Segregation Index...258`
## • `95% CI - Low` -> `95% CI - Low...265`
## • `95% CI - High` -> `95% CI - High...266`
## • `95% CI - Low` -> `95% CI - Low...268`
## • `95% CI - High` -> `95% CI - High...269`
## • `Segregation Index` -> `Segregation Index...287`
## • `95% CI - Low` -> `95% CI - Low...289`
## • `95% CI - High` -> `95% CI - High...290`
## • `95% CI - Low` -> `95% CI - Low...314`
## • `95% CI - High` -> `95% CI - High...315`
## • `95% CI - Low` -> `95% CI - Low...339`
## • `95% CI - High` -> `95% CI - High...340`
## • `95% CI - Low` -> `95% CI - Low...363`
## • `95% CI - High` -> `95% CI - High...364`
## • `95% CI - Low` -> `95% CI - Low...366`
## • `95% CI - High` -> `95% CI - High...367`
## • `95% CI - Low` -> `95% CI - Low...386`
## • `95% CI - High` -> `95% CI - High...387`
## • `95% CI - Low` -> `95% CI - Low...391`
## • `95% CI - High` -> `95% CI - High...392`
view(additional_data)
cor(additional_data$'% Food Insecure', additional_data$'% Uninsured Adults', use = "complete.obs")
## [1] 0.4554255
counties<- additional_data[-1, ]
just learned how to remove the statewide sumamry row, that way it can focus only on the counties
cor(counties$'% Food Insecure', counties$'% Uninsured Adults', use = "complete.obs")
## [1] 0.4553044
pairs(~`% Food Insecure`+`% Uninsured Adults`,data=counties)
hist(counties$`% Food Insecure`, probability = TRUE)
lines(density(na.omit(counties$`% Food Insecure`)), col = "red", lwd = 3)
hist(counties$`% Uninsured Adults`, probability = TRUE)
lines(density(na.omit(counties$`% Uninsured Adults`)), col = "red", lwd = 3)
cor.test(counties$`% Food Insecure`, counties$`% Uninsured Adults`, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: counties$`% Food Insecure` and counties$`% Uninsured Adults`
## t = 8.118, df = 252, p-value = 2.108e-14
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.3519431 0.5476956
## sample estimates:
## cor
## 0.4553044
there is a positive relationship between food insecurity and the percentage of uninsured adults across 254 Texas counties (r= 0.4553). this suggests that counties with higher rates of food insecurity also tend to have higher percentage of uninsured adults. i chose to do Pearsons correlation because the distributions were bell shaped.