This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
##Life Expectancy and Median Income Distributions #by Displacement Risk Group #KC,WA 2023
#TEST_1 SHORELINE ZIP CODES LCI
#Life Expectancy and Median Income Distributions
#by Displacement Risk Group
#KC,WA 2023
#https://gis-kingcounty.opendata.arcgis.com/maps/lci-opportunity-area-metrics-lci-opportunity-metrics-area"
###
#install.packages("tidyverse")
library(shiny)
library(rmarkdown)
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ lubridate 1.9.2 ✔ tibble 3.2.1
## ✔ purrr 1.0.1 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks plotly::filter(), stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
df1<-c()
df1<-array(1L:628174L,dim = c(628174L,14L))
df1[,]<-c(NA)
df1<-read.csv(file=c("LCI_KC_04_2023.csv"),header=T)
dff<-read.csv(file=c("LCI_KC_04_2023.csv"),header=T)
df<-select(df1,c(OBJECTID,ZIP5,
median_income,
KCA_ACRES,GEO_ID_GRP,GEO_ID_TRT, Shape_Area,
limitedEng_pct,
disabled_pct,disabled_uninsured_pct,foodstamp_pct,LifeExpectancy ,life_exp_pctle,
displacement_risk))
rm(df1)
#filter zip codes for Shoreline, WA.
#
# Extract ZIP5 code for each object ID and var into new DF
DF<-c()
DF<-data.frame()
DF<-df
rm(df1,dff)
## Warning in rm(df1, dff): object 'df1' not found
DF <- DF %>% group_by(OBJECTID)
DF$ZIP5<-as.factor(DF$ZIP5)
tidyverse_conflicts()
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks plotly::filter(), stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
#DF %>% dplyr::filter(ZIP5==levels(c(98133,98155,98160,98177)))
#DF$ZIP5==levels(c("98133","98155","98160","98177"))
#DF %>% filter(ZIP5== ("98133")|ZIP5==("98155")|ZIP5==("98160")|ZIP5==("98177")) %>% arrange(desc(median_income)) %>% head(10)
#DF %>% filter(ZIP5== ("98133")|ZIP5==("98155")|ZIP5==("98160")) %>% arrange(desc(LifeExpectancy)) %>% head(10)
#or
#DF<-c()
#DF<- df %>% filter(ZIP5== ("98133")|ZIP5==("98155")|ZIP5==("98160"))
#DF<- DF %>% filter(ZIP5 == contains('98133','98155','98160','98177'))
# filter(df, date %in% c(“Thursday”, “January”, “Sunday”))
#
#DF<-c()
DF<-c()
DF <- dplyr::filter(df,ZIP5 %in% c("98133","98155","98177"))
DF %>% na.omit() %>% ggplot(
aes(x=c(LifeExpectancy),
y=c(log(c(median_income)))))+
geom_point()+
geom_smooth(method=lm)+
facet_grid(ZIP5~.,scales="fixed")
## `geom_smooth()` using formula = 'y ~ x'
split
## function (x, f, drop = FALSE, ...)
## UseMethod("split")
## <bytecode: 0x0000025c90669168>
## <environment: namespace:base>
df0<-df
df <- dplyr::filter(df0,ZIP5 %in% c("98133","98155","98160","98177","98125"))
df<-tibble(df)
sixnumber_summ<-tapply(df$median_income,df$ZIP5,summary)
df %>% ggplot(aes(y=median_income))+geom_boxplot()+facet_grid(.~ZIP5,scales = "fixed")
df %>% ggplot(aes(y=LifeExpectancy))+geom_boxplot(aes(fill=ZIP5, color=ZIP5))+
facet_grid(.~ZIP5,scales = "fixed")
df %>% ggplot(aes(y=median_income))+geom_boxplot(aes(fill=ZIP5, color=ZIP5))+
facet_grid(.~ZIP5,scales = "fixed")+ggtitle("Boxplot of median_income by ZipCode for North Seattle/Shoreline, WA")
df %>% ggplot(aes(y=KCA_ACRES))+geom_boxplot(aes(fill=ZIP5, color=ZIP5))+
facet_grid(.~ZIP5,scales = "fixed")+ggtitle("Boxplot of KCA_ACRES by ZipCode for North Seattle/Shoreline, WA")
## Warning: Removed 311 rows containing non-finite values (`stat_boxplot()`).
df %>% arrange(desc(KCA_ACRES)) %>% head(30)
## # A tibble: 30 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <int> <int> <int> <dbl> <dbl> <dbl> <dbl>
## 1 461130 98125 80730 160. 530330002011 53033000201 6993832.
## 2 529650 98177 108533 151. 530330209003 53033020900 6464824.
## 3 419310 98177 158068 107. 530330005001 53033000500 4699067.
## 4 591291 98133 70268 77.7 530330203012 53033020301 3169142.
## 5 499674 98155 98806 75.4 530330211003 53033021100 3286731.
## 6 499644 98155 98806 72.1 530330211003 53033021100 3142544.
## 7 372292 98133 79850 71.8 530330006023 53033000602 3086333.
## 8 372288 98133 75472 63.8 530330004022 53033000402 2777579.
## 9 540657 98177 120000 45.9 530330208003 53033020800 2024810.
## 10 611896 98177 107900 44.8 530330201002 53033020100 1951783.
## # ℹ 20 more rows
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <chr>
unique(glimpse(DF)) %>% head(10)
## Rows: 31,970
## Columns: 14
## $ OBJECTID <int> 5137, 5138, 5139, 5140, 5141, 5142, 5143, 5144,…
## $ ZIP5 <int> 98133, 98133, 98133, 98133, 98133, 98133, 98133…
## $ median_income <int> 81331, 81331, 81331, 81331, 81331, 81331, 81331…
## $ KCA_ACRES <dbl> 0.1884757, 0.1884757, 0.1819789, 0.1916437, 0.1…
## $ GEO_ID_GRP <dbl> 530330207001, 530330207001, 530330207001, 53033…
## $ GEO_ID_TRT <dbl> 53033020700, 53033020700, 53033020700, 53033020…
## $ Shape_Area <dbl> 8010.657, 8146.379, 7738.160, 8237.318, 7100.41…
## $ limitedEng_pct <dbl> 0.11749516, 0.11749516, 0.11749516, 0.11749516,…
## $ disabled_pct <dbl> 0.1747239, 0.1747239, 0.1747239, 0.1747239, 0.1…
## $ disabled_uninsured_pct <dbl> 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0…
## $ foodstamp_pct <dbl> 0.10071014, 0.10071014, 0.10071014, 0.10071014,…
## $ LifeExpectancy <dbl> 78.5, 78.5, 78.5, 78.5, 78.5, 78.5, 78.5, 78.5,…
## $ life_exp_pctle <dbl> 0.1662404, 0.1662404, 0.1662404, 0.1662404, 0.1…
## $ displacement_risk <chr> "high", "high", "high", "high", "high", "high",…
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## 1 5137 98133 81331 0.1884757 530330207001 53033020700 8010.657
## 2 5138 98133 81331 0.1884757 530330207001 53033020700 8146.379
## 3 5139 98133 81331 0.1819789 530330207001 53033020700 7738.160
## 4 5140 98133 81331 0.1916437 530330207001 53033020700 8237.318
## 5 5141 98133 81331 0.1652892 530330207001 53033020700 7100.410
## 6 5142 98133 81331 0.1652892 530330207001 53033020700 7332.456
## 7 5143 98133 81331 0.1837006 530330207001 53033020700 8170.968
## 8 5144 98133 81331 0.1766070 530330207001 53033020700 7702.335
## 9 5145 98133 81331 0.1803719 530330207001 53033020700 8063.051
## 10 5146 98133 81331 0.1603535 530330207001 53033020700 7073.841
## limitedEng_pct disabled_pct disabled_uninsured_pct foodstamp_pct
## 1 0.1174952 0.1747239 0 0.1007101
## 2 0.1174952 0.1747239 0 0.1007101
## 3 0.1174952 0.1747239 0 0.1007101
## 4 0.1174952 0.1747239 0 0.1007101
## 5 0.1174952 0.1747239 0 0.1007101
## 6 0.1174952 0.1747239 0 0.1007101
## 7 0.1174952 0.1747239 0 0.1007101
## 8 0.1174952 0.1747239 0 0.1007101
## 9 0.1174952 0.1747239 0 0.1007101
## 10 0.1174952 0.1747239 0 0.1007101
## LifeExpectancy life_exp_pctle displacement_risk
## 1 78.5 0.1662404 high
## 2 78.5 0.1662404 high
## 3 78.5 0.1662404 high
## 4 78.5 0.1662404 high
## 5 78.5 0.1662404 high
## 6 78.5 0.1662404 high
## 7 78.5 0.1662404 high
## 8 78.5 0.1662404 high
## 9 78.5 0.1662404 high
## 10 78.5 0.1662404 high
df$OBJECTID<-as.factor(df$OBJECTID)
df$ZIP5<-as.factor(df$ZIP5)
df$GEO_ID_GRP<-as.factor(df$GEO_ID_GRP)
df$GEO_ID_TRT<-as.factor(df$GEO_ID_TRT)
df$displacement_risk<-as.factor(df$displacement_risk)
HighDisplcRsk<-filter(df,
displacement_risk==c("high"))
AbovMuLifeExp<-filter(df,
LifeExpectancy>76)
BelowMuLifeExp<-filter(df,
LifeExpectancy<76)
# Histogram of Life Expectancy by Displacement Group KC
hstoplt<-df %>% na.omit() %>% ggplot(aes(x = LifeExpectancy,
fill=displacement_risk,
title=c("KC Life Expectancy distribution by Displacement Risk"))) + # remember aes()
geom_histogram(bins = 30,show.legend = T)+
facet_grid(displacement_risk~.,scales="free")
print(hstoplt)
#
#
#
#Density plots for Life Expectancy distribution by Displacement Group KC
dnstyplt<-df %>% na.omit() %>% ggplot(aes(x = LifeExpectancy,
colour="lightgrey",fill=displacement_risk,
title=c("KC Life Expectancy distribution by Displacement Risk"))) + # remember aes()
geom_density(alpha=0.5)
print(dnstyplt)
#
dnstyplt1<-df %>% na.omit() %>% ggplot(aes(x = LifeExpectancy,
fill=displacement_risk,
title=c("KC Life Expectancy distribution by Displacement Risk"))) + # remember aes()
geom_density(alpha=0.35)+
facet_grid(displacement_risk~.,scales="free")
print(dnstyplt1)
#Median Income by Displacement Risk group
hstopltM<-df %>% na.omit() %>% ggplot(aes(x = median_income,
fill=displacement_risk,
title=c("KC Median Income distribution by Displacement Risk"))) + # remember aes()
geom_histogram(bins = 30,show.legend = T)+
facet_grid(displacement_risk~.)
print(hstopltM)
#
#
#
#
#Density plots
dnstypltM<-df %>% na.omit() %>% ggplot(aes(x = median_income,
colour="lightgrey",fill=displacement_risk,
title=c("KC Median Income distribution by Displacement Risk"))) + # remember aes()
geom_density(alpha=0.5)
print(dnstypltM)
#
dnstypltM1<-df %>% na.omit() %>% ggplot(aes(x = median_income,
fill=displacement_risk,
title=c("KC Median Income distribution by Displacement Risk"))) + # remember aes()
geom_density(alpha=0.35)+
facet_grid(displacement_risk~.,)
print(dnstypltM1)
#randomized normal distribution model of life expectancy(mu=76,sd=2) of size n=size of high displacement risk sample
rnorm(55157,76,sd=1) %>% hist()
##Student’s T-test for testing difference of means between sample and population #assumes normal distribution, independence, and as an, a prioi, declares the alpha (significance level) for cut off of p values #necessary for rejection ,or failure to reject the null hypothesis (H0) given particular xyz… #i.e. 1. nml dist, 2. ind sample / rep sample of population 3. sample variance and size 4. Confounding factors. 5. Design Flaws
t.test(df$LifeExpectancy,mu = c(76), conf.level = 0.95)
##
## One Sample t-test
##
## data: df$LifeExpectancy
## t = 466.55, df = 43015, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 76
## 95 percent confidence interval:
## 81.12123 81.16444
## sample estimates:
## mean of x
## 81.14284
# High Displacement Risk
#highdispl
#1 KCA Acres
HighDisplcRsk %>% arrange(desc(c(KCA_ACRES))) %>% glimpse() %>% head(10) %>% print()
## Rows: 4,769
## Columns: 14
## $ OBJECTID <fct> 591291, 578389, 472140, 585473, 578437, 378555,…
## $ ZIP5 <fct> 98133, 98133, 98133, 98133, 98133, 98125, 98133…
## $ median_income <int> 70268, 81331, 33089, 70268, 81331, 47924, 47924…
## $ KCA_ACRES <dbl> 77.689991, 25.469536, 13.189991, 11.934022, 11.…
## $ GEO_ID_GRP <fct> 530330203012, 530330207003, 530330004042, 53033…
## $ GEO_ID_TRT <fct> 53033020301, 53033020700, 53033000404, 53033020…
## $ Shape_Area <dbl> 3169142.0, 1110322.2, 574513.3, 522859.4, 51709…
## $ limitedEng_pct <dbl> 0.10607029, 0.11749516, 0.10431504, 0.10607029,…
## $ disabled_pct <dbl> 0.1726996, 0.1747239, 0.2586253, 0.1726996, 0.1…
## $ disabled_uninsured_pct <dbl> 0.00911854, 0.00000000, 0.01631452, 0.00911854,…
## $ foodstamp_pct <dbl> 0.09840256, 0.10071014, 0.12484290, 0.09840256,…
## $ LifeExpectancy <dbl> 79.7, 78.5, 80.3, 79.7, 78.5, 83.6, 83.6, 79.7,…
## $ life_exp_pctle <dbl> 0.2890026, 0.1662404, 0.3375959, 0.2890026, 0.1…
## $ displacement_risk <fct> high, high, high, high, high, high, high, high,…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 591291 98133 70268 77.7 530330203012 53033020301 3169142.
## 2 578389 98133 81331 25.5 530330207003 53033020700 1110322.
## 3 472140 98133 33089 13.2 530330004042 53033000404 574513.
## 4 585473 98133 70268 11.9 530330203011 53033020301 522859.
## 5 578437 98133 81331 11.9 530330207002 53033020700 517096.
## 6 378555 98125 47924 11.7 530330012013 53033001201 511117.
## 7 358756 98133 47924 11.1 530330012013 53033001201 483395.
## 8 585392 98133 70268 9.76 530330203011 53033020301 423285.
## 9 585465 98133 70268 9.68 530330203012 53033020301 411706.
## 10 472133 98133 37432 9.34 530330004032 53033000403 407712.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
HighDisplcRsk %>% arrange(desc(c(KCA_ACRES))) %>% glimpse() %>% tail(10) %>% print()
## Rows: 4,769
## Columns: 14
## $ OBJECTID <fct> 591291, 578389, 472140, 585473, 578437, 378555,…
## $ ZIP5 <fct> 98133, 98133, 98133, 98133, 98133, 98125, 98133…
## $ median_income <int> 70268, 81331, 33089, 70268, 81331, 47924, 47924…
## $ KCA_ACRES <dbl> 77.689991, 25.469536, 13.189991, 11.934022, 11.…
## $ GEO_ID_GRP <fct> 530330203012, 530330207003, 530330004042, 53033…
## $ GEO_ID_TRT <fct> 53033020301, 53033020700, 53033000404, 53033020…
## $ Shape_Area <dbl> 3169142.0, 1110322.2, 574513.3, 522859.4, 51709…
## $ limitedEng_pct <dbl> 0.10607029, 0.11749516, 0.10431504, 0.10607029,…
## $ disabled_pct <dbl> 0.1726996, 0.1747239, 0.2586253, 0.1726996, 0.1…
## $ disabled_uninsured_pct <dbl> 0.00911854, 0.00000000, 0.01631452, 0.00911854,…
## $ foodstamp_pct <dbl> 0.09840256, 0.10071014, 0.12484290, 0.09840256,…
## $ LifeExpectancy <dbl> 79.7, 78.5, 80.3, 79.7, 78.5, 83.6, 83.6, 79.7,…
## $ life_exp_pctle <dbl> 0.2890026, 0.1662404, 0.3375959, 0.2890026, 0.1…
## $ displacement_risk <fct> high, high, high, high, high, high, high, high,…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 548407 98133 93379 NA 530330203022 53033020302 3614.
## 2 570760 98133 37432 NA 530330004032 53033000403 9151.
## 3 578238 98133 81331 NA 530330207001 53033020700 24560.
## 4 585334 98133 70268 NA 530330203012 53033020301 566538.
## 5 607227 98133 81331 NA 530330207001 53033020700 410.
## 6 607228 98133 81331 NA 530330207001 53033020700 534.
## 7 607229 98133 81331 NA 530330207001 53033020700 3027.
## 8 616969 98133 33089 NA 530330004042 53033000404 12832.
## 9 616970 98133 37432 NA 530330004032 53033000403 134247.
## 10 618351 98133 81331 NA 530330207003 53033020700 5125.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
#2 Life Exp
HighDisplcRsk %>% arrange(desc(c(LifeExpectancy))) %>% glimpse() %>% head(10) %>% print()
## Rows: 4,769
## Columns: 14
## $ OBJECTID <fct> 44977, 47567, 71680, 73546, 125700, 125701, 125…
## $ ZIP5 <fct> 98125, 98133, 98125, 98125, 98133, 98133, 98133…
## $ median_income <int> 72660, 47924, 72660, 47924, 47924, 47924, 47924…
## $ KCA_ACRES <dbl> 1.04001377, 0.56023875, 0.14646464, 3.28507805,…
## $ GEO_ID_GRP <fct> 530330012022, 530330012012, 530330012022, 53033…
## $ GEO_ID_TRT <fct> 53033001202, 53033001201, 53033001202, 53033001…
## $ Shape_Area <dbl> 45394.704, 24386.058, 6476.793, 143104.062, 600…
## $ limitedEng_pct <dbl> 0.08263305, 0.05073996, 0.08263305, 0.05073996,…
## $ disabled_pct <dbl> 0.04982321, 0.22100922, 0.04982321, 0.22100922,…
## $ disabled_uninsured_pct <dbl> 0.00000000, 0.01722465, 0.00000000, 0.01722465,…
## $ foodstamp_pct <dbl> 0.05182073, 0.04820296, 0.05182073, 0.04820296,…
## $ LifeExpectancy <dbl> 83.6, 83.6, 83.6, 83.6, 83.6, 83.6, 83.6, 83.6,…
## $ life_exp_pctle <dbl> 0.6930946, 0.6930946, 0.6930946, 0.6930946, 0.6…
## $ displacement_risk <fct> high, high, high, high, high, high, high, high,…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 44977 98125 72660 1.04 530330012022 53033001202 45395.
## 2 47567 98133 47924 0.560 530330012012 53033001201 24386.
## 3 71680 98125 72660 0.146 530330012022 53033001202 6477.
## 4 73546 98125 47924 3.29 530330012011 53033001201 143104.
## 5 125700 98133 47924 0.138 530330012013 53033001201 6002.
## 6 125701 98133 47924 0.138 530330012013 53033001201 6002.
## 7 125702 98133 47924 0.152 530330012013 53033001201 6606.
## 8 136090 98125 72660 0.177 530330012021 53033001202 7923.
## 9 136091 98125 72660 0.153 530330012021 53033001202 6798.
## 10 136092 98125 72660 0.0779 530330012021 53033001202 3397.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
HighDisplcRsk %>% arrange(desc(c(LifeExpectancy))) %>% glimpse() %>% tail(10) %>% print()
## Rows: 4,769
## Columns: 14
## $ OBJECTID <fct> 44977, 47567, 71680, 73546, 125700, 125701, 125…
## $ ZIP5 <fct> 98125, 98133, 98125, 98125, 98133, 98133, 98133…
## $ median_income <int> 72660, 47924, 72660, 47924, 47924, 47924, 47924…
## $ KCA_ACRES <dbl> 1.04001377, 0.56023875, 0.14646464, 3.28507805,…
## $ GEO_ID_GRP <fct> 530330012022, 530330012012, 530330012022, 53033…
## $ GEO_ID_TRT <fct> 53033001202, 53033001201, 53033001202, 53033001…
## $ Shape_Area <dbl> 45394.704, 24386.058, 6476.793, 143104.062, 600…
## $ limitedEng_pct <dbl> 0.08263305, 0.05073996, 0.08263305, 0.05073996,…
## $ disabled_pct <dbl> 0.04982321, 0.22100922, 0.04982321, 0.22100922,…
## $ disabled_uninsured_pct <dbl> 0.00000000, 0.01722465, 0.00000000, 0.01722465,…
## $ foodstamp_pct <dbl> 0.05182073, 0.04820296, 0.05182073, 0.04820296,…
## $ LifeExpectancy <dbl> 83.6, 83.6, 83.6, 83.6, 83.6, 83.6, 83.6, 83.6,…
## $ life_exp_pctle <dbl> 0.6930946, 0.6930946, 0.6930946, 0.6930946, 0.6…
## $ displacement_risk <fct> high, high, high, high, high, high, high, high,…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 607228 98133 81331 NA 530330207001 53033020700 534.
## 2 607229 98133 81331 NA 530330207001 53033020700 3027.
## 3 607230 98133 81331 0.0722 530330207001 53033020700 3282.
## 4 607231 98133 81331 0.0512 530330207001 53033020700 2325.
## 5 607232 98133 81331 0.0512 530330207001 53033020700 2322.
## 6 607233 98133 81331 0.0651 530330207001 53033020700 2940.
## 7 607234 98133 81331 0.0801 530330207001 53033020700 3645.
## 8 607235 98133 81331 0.0770 530330207001 53033020700 3510.
## 9 607236 98133 81331 0.0773 530330207001 53033020700 3529.
## 10 618351 98133 81331 NA 530330207003 53033020700 5125.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
#3 Median income
HighDisplcRsk %>% arrange(desc(c(median_income))) %>% glimpse() %>% head(10) %>% print()
## Rows: 4,769
## Columns: 14
## $ OBJECTID <fct> 35552, 35553, 35554, 35555, 35556, 35557, 35558…
## $ ZIP5 <fct> 98133, 98133, 98133, 98133, 98133, 98133, 98133…
## $ median_income <int> 93379, 93379, 93379, 93379, 93379, 93379, 93379…
## $ KCA_ACRES <dbl> 0.1652892, 0.1652892, 0.1652892, 0.1631543, 0.1…
## $ GEO_ID_GRP <fct> 530330203023, 530330203023, 530330203023, 53033…
## $ GEO_ID_TRT <fct> 53033020302, 53033020302, 53033020302, 53033020…
## $ Shape_Area <dbl> 7196.958, 7196.874, 7196.911, 7101.303, 7192.10…
## $ limitedEng_pct <dbl> 0.06317301, 0.06317301, 0.06317301, 0.06317301,…
## $ disabled_pct <dbl> 0.1835697, 0.1835697, 0.1835697, 0.1835697, 0.1…
## $ disabled_uninsured_pct <dbl> 0.00856302, 0.00856302, 0.00856302, 0.00856302,…
## $ foodstamp_pct <dbl> 0.03374013, 0.03374013, 0.03374013, 0.03374013,…
## $ LifeExpectancy <dbl> 79.7, 79.7, 79.7, 79.7, 79.7, 79.7, 79.7, 79.7,…
## $ life_exp_pctle <dbl> 0.2890026, 0.2890026, 0.2890026, 0.2890026, 0.2…
## $ displacement_risk <fct> high, high, high, high, high, high, high, high,…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 35552 98133 93379 0.165 530330203023 53033020302 7197.
## 2 35553 98133 93379 0.165 530330203023 53033020302 7197.
## 3 35554 98133 93379 0.165 530330203023 53033020302 7197.
## 4 35555 98133 93379 0.163 530330203023 53033020302 7101.
## 5 35556 98133 93379 0.165 530330203023 53033020302 7192.
## 6 35557 98133 93379 0.167 530330203023 53033020302 7283.
## 7 35558 98133 93379 0.175 530330203023 53033020302 7629.
## 8 35559 98133 93379 0.170 530330203023 53033020302 7409.
## 9 35560 98133 93379 0.167 530330203023 53033020302 7285.
## 10 35561 98133 93379 0.177 530330203023 53033020302 7717.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
HighDisplcRsk %>% arrange(desc(c(median_income))) %>% glimpse() %>% tail(10) %>% print()
## Rows: 4,769
## Columns: 14
## $ OBJECTID <fct> 35552, 35553, 35554, 35555, 35556, 35557, 35558…
## $ ZIP5 <fct> 98133, 98133, 98133, 98133, 98133, 98133, 98133…
## $ median_income <int> 93379, 93379, 93379, 93379, 93379, 93379, 93379…
## $ KCA_ACRES <dbl> 0.1652892, 0.1652892, 0.1652892, 0.1631543, 0.1…
## $ GEO_ID_GRP <fct> 530330203023, 530330203023, 530330203023, 53033…
## $ GEO_ID_TRT <fct> 53033020302, 53033020302, 53033020302, 53033020…
## $ Shape_Area <dbl> 7196.958, 7196.874, 7196.911, 7101.303, 7192.10…
## $ limitedEng_pct <dbl> 0.06317301, 0.06317301, 0.06317301, 0.06317301,…
## $ disabled_pct <dbl> 0.1835697, 0.1835697, 0.1835697, 0.1835697, 0.1…
## $ disabled_uninsured_pct <dbl> 0.00856302, 0.00856302, 0.00856302, 0.00856302,…
## $ foodstamp_pct <dbl> 0.03374013, 0.03374013, 0.03374013, 0.03374013,…
## $ LifeExpectancy <dbl> 79.7, 79.7, 79.7, 79.7, 79.7, 79.7, 79.7, 79.7,…
## $ life_exp_pctle <dbl> 0.2890026, 0.2890026, 0.2890026, 0.2890026, 0.2…
## $ displacement_risk <fct> high, high, high, high, high, high, high, high,…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 617068 98133 33089 0.383 530330004042 53033000404 16679.
## 2 617069 98133 33089 3.60 530330004042 53033000404 156782.
## 3 617070 98133 33089 1.23 530330004042 53033000404 53628.
## 4 617071 98133 33089 0.580 530330004042 53033000404 25220.
## 5 617072 98133 33089 0.574 530330004043 53033000404 25003.
## 6 617073 98133 33089 0.689 530330004043 53033000404 29966.
## 7 617074 98133 33089 2.00 530330004043 53033000404 87203.
## 8 617075 98133 33089 0.581 530330004043 53033000404 25286.
## 9 617076 98133 33089 1.19 530330004043 53033000404 51852.
## 10 617077 98133 33089 2.47 530330004043 53033000404 106168.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
#summary of highdisplcrsk
summary(HighDisplcRsk) %>% as.array()%>%View()
summary(HighDisplcRsk) %>% as.array() %>% print()
## OBJECTID ZIP5 median_income KCA_ACRES
## 5137 : 1 98125: 925 Min. :33089 Min. : 0.00234
## 5138 : 1 98133:3592 1st Qu.:47924 1st Qu.: 0.15496
## 5139 : 1 98155: 19 Median :72660 Median : 0.18307
## 5140 : 1 98177: 233 Mean :70283 Mean : 0.30433
## 5141 : 1 3rd Qu.:81331 3rd Qu.: 0.21970
## 5142 : 1 Max. :93379 Max. :77.68999
## (Other):4763 NA's :55
## GEO_ID_GRP GEO_ID_TRT Shape_Area limitedEng_pct
## 530330203023: 506 53033020700:1087 Min. : 180 Min. :0.05074
## 530330203021: 485 53033020302:1056 1st Qu.: 6735 1st Qu.:0.06317
## 530330207003: 474 53033001202: 761 Median : 7941 Median :0.08263
## 530330012021: 418 53033020301: 645 Mean : 13339 Mean :0.08657
## 530330203011: 405 53033000403: 529 3rd Qu.: 9591 3rd Qu.:0.10607
## 530330004031: 389 53033000404: 362 Max. :3169142 Max. :0.11750
## (Other) :2092 (Other) : 329
## disabled_pct disabled_uninsured_pct foodstamp_pct LifeExpectancy
## Min. :0.04982 Min. :0.000000 Min. :0.03374 Min. :78.50
## 1st Qu.:0.17270 1st Qu.:0.000000 1st Qu.:0.04820 1st Qu.:79.70
## Median :0.17472 Median :0.008563 Median :0.09840 Median :79.70
## Mean :0.16898 Mean :0.005556 Mean :0.08129 Mean :80.43
## 3rd Qu.:0.20121 3rd Qu.:0.009119 3rd Qu.:0.10071 3rd Qu.:80.30
## Max. :0.25863 Max. :0.017225 Max. :0.14857 Max. :83.60
##
## life_exp_pctle displacement_risk
## Min. :0.1662 high :4769
## 1st Qu.:0.2890 low : 0
## Median :0.2890 moderate: 0
## Mean :0.3625
## 3rd Qu.:0.3376
## Max. :0.6931
##
AbovMuLifeExp
## # A tibble: 41,620 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 15 98125 76888 0.222 530330007002 53033000700 9602.
## 2 16 98125 76888 0.222 530330007002 53033000700 9623.
## 3 17 98125 76888 0.165 530330007002 53033000700 7217.
## 4 18 98125 76888 0.277 530330007002 53033000700 12097.
## 5 19 98125 76888 0.220 530330007002 53033000700 9652.
## 6 20 98125 76888 0.222 530330007002 53033000700 9703.
## 7 21 98125 76888 0.222 530330007002 53033000700 9724.
## 8 22 98125 76888 0.222 530330007002 53033000700 9673.
## 9 23 98125 76888 0.147 530330007002 53033000700 6431.
## 10 24 98125 76888 0.152 530330007002 53033000700 6616.
## # ℹ 41,610 more rows
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
##1 KCA Acres
AbovMuLifeExp%>% arrange(desc(c(KCA_ACRES))) %>% head(10) %>% print()
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 461130 98125 80730 160. 530330002011 53033000201 6993832.
## 2 529650 98177 108533 151. 530330209003 53033020900 6464824.
## 3 419310 98177 158068 107. 530330005001 53033000500 4699067.
## 4 591291 98133 70268 77.7 530330203012 53033020301 3169142.
## 5 372292 98133 79850 71.8 530330006023 53033000602 3086333.
## 6 372288 98133 75472 63.8 530330004022 53033000402 2777579.
## 7 540657 98177 120000 45.9 530330208003 53033020800 2024810.
## 8 611896 98177 107900 44.8 530330201002 53033020100 1951783.
## 9 585468 98133 70417 43.5 530330202001 53033020200 1906710.
## 10 591290 98155 88839 39.6 530330204012 53033020401 1644569.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
AbovMuLifeExp %>% arrange(desc(c(KCA_ACRES))) %>% tail(10) %>% print()
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 607229 98133 81331 NA 530330207001 53033020700 3027.
## 2 611644 98177 107900 NA 530330201003 53033020100 14677.
## 3 611645 98177 107900 NA 530330201002 53033020100 5206.
## 4 615795 98155 152852 NA 530330215004 53033021500 8471.
## 5 616969 98133 33089 NA 530330004042 53033000404 12832.
## 6 616970 98133 37432 NA 530330004032 53033000403 134247.
## 7 618349 98133 70417 NA 530330202004 53033020200 29995.
## 8 618350 98177 70417 NA 530330202004 53033020200 13897.
## 9 618351 98133 81331 NA 530330207003 53033020700 5125.
## 10 621813 98177 104095 NA 530330014003 53033001400 40489.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
##2 Life 10
AbovMuLifeExp %>% arrange(desc(c(LifeExpectancy))) %>% head(10) %>% print()
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 200614 98177 142063 0.240 530330015001 53033001500 10340.
## 2 200621 98177 142063 0.142 530330015001 53033001500 6054.
## 3 200622 98177 142063 0.150 530330015001 53033001500 6444.
## 4 18157 98125 140769 0.117 530330022001 53033002200 5070.
## 5 18158 98125 140769 0.117 530330022001 53033002200 5070.
## 6 18159 98125 140769 0.124 530330022001 53033002200 5388.
## 7 18160 98125 140769 0.179 530330022001 53033002200 7763.
## 8 18161 98125 140769 0.179 530330022001 53033002200 7763.
## 9 18162 98125 140769 0.179 530330022001 53033002200 7762.
## 10 18163 98125 140769 0.179 530330022001 53033002200 7762.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
AbovMuLifeExp %>% arrange(desc(c(LifeExpectancy))) %>% tail(10) %>% print()
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 562704 98155 92273 0.202 530330213003 53033021300 8766.
## 2 562705 98155 92273 0.202 530330213003 53033021300 8776.
## 3 562706 98155 92273 0.303 530330213003 53033021300 13172.
## 4 562707 98155 92273 0.202 530330213003 53033021300 8721.
## 5 562708 98155 92273 0.202 530330213003 53033021300 8730.
## 6 562709 98155 92273 0.202 530330213003 53033021300 8739.
## 7 562710 98155 92273 0.202 530330213003 53033021300 8748.
## 8 562711 98155 92273 0.202 530330213003 53033021300 8757.
## 9 562712 98155 92273 0.202 530330213003 53033021300 8766.
## 10 562713 98155 92273 0.202 530330213003 53033021300 8775.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
##3 median income
AbovMuLifeExp %>% arrange(desc(c(median_income))) %>% head(10) %>% print()
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 40327 98177 172232 0.196 530330016001 53033001600 8649.
## 2 40328 98177 172232 0.196 530330016001 53033001600 8596.
## 3 40329 98177 172232 0.149 530330016001 53033001600 6533.
## 4 40332 98177 172232 0.184 530330016001 53033001600 8015.
## 5 202586 98177 172232 0.187 530330016001 53033001600 9175.
## 6 202587 98177 172232 0.164 530330016001 53033001600 7396.
## 7 202588 98177 172232 0.206 530330016001 53033001600 9075.
## 8 202589 98177 172232 0.224 530330016001 53033001600 9529.
## 9 253199 98177 172232 0.120 530330016001 53033001600 5357.
## 10 253200 98177 172232 0.114 530330016001 53033001600 4992.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
AbovMuLifeExp %>% arrange(desc(c(median_income))) %>% tail(10) %>% print()
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 617068 98133 33089 0.383 530330004042 53033000404 16679.
## 2 617069 98133 33089 3.60 530330004042 53033000404 156782.
## 3 617070 98133 33089 1.23 530330004042 53033000404 53628.
## 4 617071 98133 33089 0.580 530330004042 53033000404 25220.
## 5 617072 98133 33089 0.574 530330004043 53033000404 25003.
## 6 617073 98133 33089 0.689 530330004043 53033000404 29966.
## 7 617074 98133 33089 2.00 530330004043 53033000404 87203.
## 8 617075 98133 33089 0.581 530330004043 53033000404 25286.
## 9 617076 98133 33089 1.19 530330004043 53033000404 51852.
## 10 617077 98133 33089 2.47 530330004043 53033000404 106168.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
## summary of aboveMuLifeExp
summary(AbovMuLifeExp) %>% as.array()%>% View()
summary(AbovMuLifeExp) %>% as.array() %>% print()
## OBJECTID ZIP5 median_income KCA_ACRES
## 15 : 1 98125:11046 Min. : 33089 Min. : 0.0000
## 16 : 1 98133:12603 1st Qu.: 79850 1st Qu.: 0.1627
## 17 : 1 98155:10372 Median :101897 Median : 0.1866
## 18 : 1 98177: 7599 Mean : 99891 Mean : 0.3068
## 19 : 1 3rd Qu.:108533 3rd Qu.: 0.2384
## 20 : 1 Max. :172232 Max. :160.3800
## (Other):41614 NA's :306
## GEO_ID_GRP GEO_ID_TRT Shape_Area limitedEng_pct
## 530330005001: 760 53033020500: 2153 Min. : 20 Min. :0.00000
## 530330005002: 690 53033021000: 1931 1st Qu.: 7046 1st Qu.:0.02141
## 530330214002: 653 53033020200: 1786 Median : 8130 Median :0.04674
## 530330208003: 615 53033020402: 1648 Mean : 14449 Mean :0.05068
## 530330001021: 601 53033020800: 1602 3rd Qu.: 10418 3rd Qu.:0.08263
## 530330003002: 595 53033021400: 1598 Max. :11467259 Max. :0.11750
## (Other) :37706 (Other) :30902
## disabled_pct disabled_uninsured_pct foodstamp_pct LifeExpectancy
## Min. :0.04982 Min. :0.000000 Min. :0.00000 Min. :76.80
## 1st Qu.:0.08900 1st Qu.:0.000000 1st Qu.:0.01971 1st Qu.:79.90
## Median :0.10225 Median :0.002367 Median :0.03679 Median :81.00
## Mean :0.12161 Mean :0.003935 Mean :0.04242 Mean :81.37
## 3rd Qu.:0.15048 3rd Qu.:0.006522 3rd Qu.:0.06364 3rd Qu.:82.60
## Max. :0.25863 Max. :0.017225 Max. :0.14857 Max. :87.80
##
## life_exp_pctle displacement_risk
## Min. :0.08951 high : 4769
## 1st Qu.:0.31202 low :17064
## Median :0.42967 moderate:19787
## Mean :0.46175
## 3rd Qu.:0.58824
## Max. :0.95652
##
# Below Mu (mu=76) Life Expectancy
## BelowMuLifeExp
#1 KCA Acres
BelowMuLifeExp %>% arrange(desc(c(KCA_ACRES))) %>% glimpse() %>% head(10) %>% print()
## Rows: 1,396
## Columns: 14
## $ OBJECTID <fct> 499674, 499644, 499675, 499676, 499624, 202537,…
## $ ZIP5 <fct> 98155, 98155, 98155, 98155, 98155, 98155, 98155…
## $ median_income <int> 98806, 98806, 98806, 98806, 98806, 98806, 98806…
## $ KCA_ACRES <dbl> 75.3799128, 72.1000000, 43.8799816, 20.5399908,…
## $ GEO_ID_GRP <fct> 530330211003, 530330211003, 530330211003, 53033…
## $ GEO_ID_TRT <fct> 53033021100, 53033021100, 53033021100, 53033021…
## $ Shape_Area <dbl> 3286731.21, 3142544.49, 1909500.79, 895327.54, …
## $ limitedEng_pct <dbl> 0.06215385, 0.06215385, 0.06215385, 0.06215385,…
## $ disabled_pct <dbl> 0.07305081, 0.07305081, 0.07305081, 0.07305081,…
## $ disabled_uninsured_pct <dbl> 0.00351206, 0.00351206, 0.00351206, 0.00351206,…
## $ foodstamp_pct <dbl> 0.02769231, 0.02769231, 0.02769231, 0.02769231,…
## $ LifeExpectancy <dbl> 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4,…
## $ life_exp_pctle <dbl> 0.01534527, 0.01534527, 0.01534527, 0.01534527,…
## $ displacement_risk <fct> moderate, moderate, moderate, moderate, moderat…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 499674 98155 98806 75.4 530330211003 53033021100 3286731.
## 2 499644 98155 98806 72.1 530330211003 53033021100 3142544.
## 3 499675 98155 98806 43.9 530330211003 53033021100 1909501.
## 4 499676 98155 98806 20.5 530330211003 53033021100 895328.
## 5 499624 98155 98806 12.6 530330211003 53033021100 549735.
## 6 202537 98155 98806 8.57 530330211002 53033021100 372503.
## 7 182501 98155 98806 5.58 530330211002 53033021100 243315.
## 8 499665 98155 98806 4.93 530330211003 53033021100 213777.
## 9 499629 98155 98806 4.79 530330211003 53033021100 208390.
## 10 499666 98155 98806 4.03 530330211003 53033021100 175333.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
BelowMuLifeExp %>% arrange(desc(c(KCA_ACRES))) %>% glimpse() %>% tail(10) %>% print()
## Rows: 1,396
## Columns: 14
## $ OBJECTID <fct> 499674, 499644, 499675, 499676, 499624, 202537,…
## $ ZIP5 <fct> 98155, 98155, 98155, 98155, 98155, 98155, 98155…
## $ median_income <int> 98806, 98806, 98806, 98806, 98806, 98806, 98806…
## $ KCA_ACRES <dbl> 75.3799128, 72.1000000, 43.8799816, 20.5399908,…
## $ GEO_ID_GRP <fct> 530330211003, 530330211003, 530330211003, 53033…
## $ GEO_ID_TRT <fct> 53033021100, 53033021100, 53033021100, 53033021…
## $ Shape_Area <dbl> 3286731.21, 3142544.49, 1909500.79, 895327.54, …
## $ limitedEng_pct <dbl> 0.06215385, 0.06215385, 0.06215385, 0.06215385,…
## $ disabled_pct <dbl> 0.07305081, 0.07305081, 0.07305081, 0.07305081,…
## $ disabled_uninsured_pct <dbl> 0.00351206, 0.00351206, 0.00351206, 0.00351206,…
## $ foodstamp_pct <dbl> 0.02769231, 0.02769231, 0.02769231, 0.02769231,…
## $ LifeExpectancy <dbl> 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4,…
## $ life_exp_pctle <dbl> 0.01534527, 0.01534527, 0.01534527, 0.01534527,…
## $ displacement_risk <fct> moderate, moderate, moderate, moderate, moderat…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 330771 98155 98806 0.0104 530330211001 53033021100 447.
## 2 499625 98155 98806 0 530330211003 53033021100 169544.
## 3 499626 98155 98806 0 530330211003 53033021100 208390.
## 4 499627 98155 98806 0 530330211003 53033021100 130526.
## 5 499631 98155 98806 0 530330211003 53033021100 169666.
## 6 143812 98155 98806 NA 530330211001 53033021100 5351.
## 7 182479 98155 98806 NA 530330211002 53033021100 59292.
## 8 182480 98155 98806 NA 530330211002 53033021100 9075.
## 9 192800 98155 98806 NA 530330211002 53033021100 9906.
## 10 499618 98155 98806 NA 530330211003 53033021100 2876.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
## 2 Life Exp
BelowMuLifeExp %>% arrange(desc(c(LifeExpectancy))) %>% glimpse() %>% head(10) %>% print()
## Rows: 1,396
## Columns: 14
## $ OBJECTID <fct> 80520, 127273, 127274, 127275, 127276, 127277, …
## $ ZIP5 <fct> 98155, 98155, 98155, 98155, 98155, 98155, 98155…
## $ median_income <int> 98806, 98806, 98806, 98806, 98806, 98806, 98806…
## $ KCA_ACRES <dbl> 0.8104224, 0.1721763, 0.1198347, 0.1707989, 0.1…
## $ GEO_ID_GRP <fct> 530330211002, 530330211002, 530330211002, 53033…
## $ GEO_ID_TRT <fct> 53033021100, 53033021100, 53033021100, 53033021…
## $ Shape_Area <dbl> 35295.297, 7499.673, 5275.584, 7453.665, 7451.4…
## $ limitedEng_pct <dbl> 0.06215385, 0.06215385, 0.06215385, 0.06215385,…
## $ disabled_pct <dbl> 0.07305081, 0.07305081, 0.07305081, 0.07305081,…
## $ disabled_uninsured_pct <dbl> 0.00351206, 0.00351206, 0.00351206, 0.00351206,…
## $ foodstamp_pct <dbl> 0.02769231, 0.02769231, 0.02769231, 0.02769231,…
## $ LifeExpectancy <dbl> 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4,…
## $ life_exp_pctle <dbl> 0.01534527, 0.01534527, 0.01534527, 0.01534527,…
## $ displacement_risk <fct> moderate, moderate, moderate, moderate, moderat…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 80520 98155 98806 0.810 530330211002 53033021100 35295.
## 2 127273 98155 98806 0.172 530330211002 53033021100 7500.
## 3 127274 98155 98806 0.120 530330211002 53033021100 5276.
## 4 127275 98155 98806 0.171 530330211002 53033021100 7454.
## 5 127276 98155 98806 0.171 530330211002 53033021100 7451.
## 6 127277 98155 98806 0.171 530330211002 53033021100 7450.
## 7 127278 98155 98806 0.171 530330211002 53033021100 7447.
## 8 127279 98155 98806 0.171 530330211002 53033021100 7445.
## 9 127280 98155 98806 0.171 530330211002 53033021100 7443.
## 10 127281 98155 98806 0.171 530330211002 53033021100 7441.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
BelowMuLifeExp %>% arrange(desc(c(LifeExpectancy))) %>% glimpse() %>% tail(10) %>% print()
## Rows: 1,396
## Columns: 14
## $ OBJECTID <fct> 80520, 127273, 127274, 127275, 127276, 127277, …
## $ ZIP5 <fct> 98155, 98155, 98155, 98155, 98155, 98155, 98155…
## $ median_income <int> 98806, 98806, 98806, 98806, 98806, 98806, 98806…
## $ KCA_ACRES <dbl> 0.8104224, 0.1721763, 0.1198347, 0.1707989, 0.1…
## $ GEO_ID_GRP <fct> 530330211002, 530330211002, 530330211002, 53033…
## $ GEO_ID_TRT <fct> 53033021100, 53033021100, 53033021100, 53033021…
## $ Shape_Area <dbl> 35295.297, 7499.673, 5275.584, 7453.665, 7451.4…
## $ limitedEng_pct <dbl> 0.06215385, 0.06215385, 0.06215385, 0.06215385,…
## $ disabled_pct <dbl> 0.07305081, 0.07305081, 0.07305081, 0.07305081,…
## $ disabled_uninsured_pct <dbl> 0.00351206, 0.00351206, 0.00351206, 0.00351206,…
## $ foodstamp_pct <dbl> 0.02769231, 0.02769231, 0.02769231, 0.02769231,…
## $ LifeExpectancy <dbl> 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4,…
## $ life_exp_pctle <dbl> 0.01534527, 0.01534527, 0.01534527, 0.01534527,…
## $ displacement_risk <fct> moderate, moderate, moderate, moderate, moderat…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 499675 98155 98806 43.9 530330211003 53033021100 1909501.
## 2 499676 98155 98806 20.5 530330211003 53033021100 895328.
## 3 508013 98155 98806 0.186 530330211003 53033021100 8063.
## 4 577790 98155 98806 1.09 530330211003 53033021100 47818.
## 5 583871 98155 98806 0.277 530330211002 53033021100 12016.
## 6 583872 98155 98806 0.158 530330211002 53033021100 6890.
## 7 583873 98155 98806 0.227 530330211002 53033021100 9975.
## 8 583874 98155 98806 0.228 530330211002 53033021100 9933.
## 9 583875 98155 98806 0.153 530330211002 53033021100 6472.
## 10 583876 98155 98806 0.287 530330211002 53033021100 12441.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
## 3 median income
BelowMuLifeExp %>% arrange(desc(c(median_income))) %>% glimpse() %>% head(10) %>% print()
## Rows: 1,396
## Columns: 14
## $ OBJECTID <fct> 80520, 127273, 127274, 127275, 127276, 127277, …
## $ ZIP5 <fct> 98155, 98155, 98155, 98155, 98155, 98155, 98155…
## $ median_income <int> 98806, 98806, 98806, 98806, 98806, 98806, 98806…
## $ KCA_ACRES <dbl> 0.8104224, 0.1721763, 0.1198347, 0.1707989, 0.1…
## $ GEO_ID_GRP <fct> 530330211002, 530330211002, 530330211002, 53033…
## $ GEO_ID_TRT <fct> 53033021100, 53033021100, 53033021100, 53033021…
## $ Shape_Area <dbl> 35295.297, 7499.673, 5275.584, 7453.665, 7451.4…
## $ limitedEng_pct <dbl> 0.06215385, 0.06215385, 0.06215385, 0.06215385,…
## $ disabled_pct <dbl> 0.07305081, 0.07305081, 0.07305081, 0.07305081,…
## $ disabled_uninsured_pct <dbl> 0.00351206, 0.00351206, 0.00351206, 0.00351206,…
## $ foodstamp_pct <dbl> 0.02769231, 0.02769231, 0.02769231, 0.02769231,…
## $ LifeExpectancy <dbl> 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4,…
## $ life_exp_pctle <dbl> 0.01534527, 0.01534527, 0.01534527, 0.01534527,…
## $ displacement_risk <fct> moderate, moderate, moderate, moderate, moderat…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 80520 98155 98806 0.810 530330211002 53033021100 35295.
## 2 127273 98155 98806 0.172 530330211002 53033021100 7500.
## 3 127274 98155 98806 0.120 530330211002 53033021100 5276.
## 4 127275 98155 98806 0.171 530330211002 53033021100 7454.
## 5 127276 98155 98806 0.171 530330211002 53033021100 7451.
## 6 127277 98155 98806 0.171 530330211002 53033021100 7450.
## 7 127278 98155 98806 0.171 530330211002 53033021100 7447.
## 8 127279 98155 98806 0.171 530330211002 53033021100 7445.
## 9 127280 98155 98806 0.171 530330211002 53033021100 7443.
## 10 127281 98155 98806 0.171 530330211002 53033021100 7441.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
BelowMuLifeExp %>% arrange(desc(c(median_income))) %>% glimpse() %>% tail(10) %>% print()
## Rows: 1,396
## Columns: 14
## $ OBJECTID <fct> 80520, 127273, 127274, 127275, 127276, 127277, …
## $ ZIP5 <fct> 98155, 98155, 98155, 98155, 98155, 98155, 98155…
## $ median_income <int> 98806, 98806, 98806, 98806, 98806, 98806, 98806…
## $ KCA_ACRES <dbl> 0.8104224, 0.1721763, 0.1198347, 0.1707989, 0.1…
## $ GEO_ID_GRP <fct> 530330211002, 530330211002, 530330211002, 53033…
## $ GEO_ID_TRT <fct> 53033021100, 53033021100, 53033021100, 53033021…
## $ Shape_Area <dbl> 35295.297, 7499.673, 5275.584, 7453.665, 7451.4…
## $ limitedEng_pct <dbl> 0.06215385, 0.06215385, 0.06215385, 0.06215385,…
## $ disabled_pct <dbl> 0.07305081, 0.07305081, 0.07305081, 0.07305081,…
## $ disabled_uninsured_pct <dbl> 0.00351206, 0.00351206, 0.00351206, 0.00351206,…
## $ foodstamp_pct <dbl> 0.02769231, 0.02769231, 0.02769231, 0.02769231,…
## $ LifeExpectancy <dbl> 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4, 74.4,…
## $ life_exp_pctle <dbl> 0.01534527, 0.01534527, 0.01534527, 0.01534527,…
## $ displacement_risk <fct> moderate, moderate, moderate, moderate, moderat…
## # A tibble: 10 × 14
## OBJECTID ZIP5 median_income KCA_ACRES GEO_ID_GRP GEO_ID_TRT Shape_Area
## <fct> <fct> <int> <dbl> <fct> <fct> <dbl>
## 1 499675 98155 98806 43.9 530330211003 53033021100 1909501.
## 2 499676 98155 98806 20.5 530330211003 53033021100 895328.
## 3 508013 98155 98806 0.186 530330211003 53033021100 8063.
## 4 577790 98155 98806 1.09 530330211003 53033021100 47818.
## 5 583871 98155 98806 0.277 530330211002 53033021100 12016.
## 6 583872 98155 98806 0.158 530330211002 53033021100 6890.
## 7 583873 98155 98806 0.227 530330211002 53033021100 9975.
## 8 583874 98155 98806 0.228 530330211002 53033021100 9933.
## 9 583875 98155 98806 0.153 530330211002 53033021100 6472.
## 10 583876 98155 98806 0.287 530330211002 53033021100 12441.
## # ℹ 7 more variables: limitedEng_pct <dbl>, disabled_pct <dbl>,
## # disabled_uninsured_pct <dbl>, foodstamp_pct <dbl>, LifeExpectancy <dbl>,
## # life_exp_pctle <dbl>, displacement_risk <fct>
## summary of BelowMuLifeExp
summary(BelowMuLifeExp) %>% as.array()
## OBJECTID ZIP5 median_income KCA_ACRES
## 80520 : 1 98125: 0 Min. :98806 Min. : 0.0000
## 127273 : 1 98133: 0 1st Qu.:98806 1st Qu.: 0.1708
## 127274 : 1 98155:1396 Median :98806 Median : 0.1869
## 127275 : 1 98177: 0 Mean :98806 Mean : 0.3981
## 127276 : 1 3rd Qu.:98806 3rd Qu.: 0.1993
## 127277 : 1 Max. :98806 Max. :75.3799
## (Other):1390 NA's :5
## GEO_ID_GRP GEO_ID_TRT Shape_Area limitedEng_pct
## 530330211001:635 53033021100:1396 Min. : 447 Min. :0.06215
## 530330211002:444 53033000101: 0 1st Qu.: 7433 1st Qu.:0.06215
## 530330211003:317 53033000102: 0 Median : 8117 Median :0.06215
## 530330001011: 0 53033000201: 0 Mean : 17829 Mean :0.06215
## 530330001012: 0 53033000202: 0 3rd Qu.: 8675 3rd Qu.:0.06215
## 530330001013: 0 53033000300: 0 Max. :3286731 Max. :0.06215
## (Other) : 0 (Other) : 0
## disabled_pct disabled_uninsured_pct foodstamp_pct LifeExpectancy
## Min. :0.07305 Min. :0.003512 Min. :0.02769 Min. :74.4
## 1st Qu.:0.07305 1st Qu.:0.003512 1st Qu.:0.02769 1st Qu.:74.4
## Median :0.07305 Median :0.003512 Median :0.02769 Median :74.4
## Mean :0.07305 Mean :0.003512 Mean :0.02769 Mean :74.4
## 3rd Qu.:0.07305 3rd Qu.:0.003512 3rd Qu.:0.02769 3rd Qu.:74.4
## Max. :0.07305 Max. :0.003512 Max. :0.02769 Max. :74.4
##
## life_exp_pctle displacement_risk
## Min. :0.01535 high : 0
## 1st Qu.:0.01535 low : 0
## Median :0.01535 moderate:1396
## Mean :0.01535
## 3rd Qu.:0.01535
## Max. :0.01535
##
summary(BelowMuLifeExp) %>% as.array() %>% print()
## OBJECTID ZIP5 median_income KCA_ACRES
## 80520 : 1 98125: 0 Min. :98806 Min. : 0.0000
## 127273 : 1 98133: 0 1st Qu.:98806 1st Qu.: 0.1708
## 127274 : 1 98155:1396 Median :98806 Median : 0.1869
## 127275 : 1 98177: 0 Mean :98806 Mean : 0.3981
## 127276 : 1 3rd Qu.:98806 3rd Qu.: 0.1993
## 127277 : 1 Max. :98806 Max. :75.3799
## (Other):1390 NA's :5
## GEO_ID_GRP GEO_ID_TRT Shape_Area limitedEng_pct
## 530330211001:635 53033021100:1396 Min. : 447 Min. :0.06215
## 530330211002:444 53033000101: 0 1st Qu.: 7433 1st Qu.:0.06215
## 530330211003:317 53033000102: 0 Median : 8117 Median :0.06215
## 530330001011: 0 53033000201: 0 Mean : 17829 Mean :0.06215
## 530330001012: 0 53033000202: 0 3rd Qu.: 8675 3rd Qu.:0.06215
## 530330001013: 0 53033000300: 0 Max. :3286731 Max. :0.06215
## (Other) : 0 (Other) : 0
## disabled_pct disabled_uninsured_pct foodstamp_pct LifeExpectancy
## Min. :0.07305 Min. :0.003512 Min. :0.02769 Min. :74.4
## 1st Qu.:0.07305 1st Qu.:0.003512 1st Qu.:0.02769 1st Qu.:74.4
## Median :0.07305 Median :0.003512 Median :0.02769 Median :74.4
## Mean :0.07305 Mean :0.003512 Mean :0.02769 Mean :74.4
## 3rd Qu.:0.07305 3rd Qu.:0.003512 3rd Qu.:0.02769 3rd Qu.:74.4
## Max. :0.07305 Max. :0.003512 Max. :0.02769 Max. :74.4
##
## life_exp_pctle displacement_risk
## Min. :0.01535 high : 0
## 1st Qu.:0.01535 low : 0
## Median :0.01535 moderate:1396
## Mean :0.01535
## 3rd Qu.:0.01535
## Max. :0.01535
##
# Boxplot of Life Expectancy LCI Areas
# KC,WA 2023
#
boxplot(x=c(df$LifeExpectancy),col="blue",fill='blue',main = c("Boxplot of Life Expectancy LCI Areas KC,WA 2023"),
ylab=c("AGE in YEARS"),xlab=c())
hst<-hist(df$LifeExpectancy,col=c("blue","green"),main = c("Life Expectancy by LCI Areas KC,WA 2023"),
xlab=c("AGE in YEARS"),ylab=c("Counts/Frequency"))
#
#
#
628174*47
## [1] 29524178
56065*14
## [1] 784910
plotly() package contains the ggplotly() function which converts static graphs made in ggplot2() to user-interactive dynamic graphs. An example of this is shown below for this project/example.
library("ggplot2")
library("plotly")
#
#plotly package of density maps made from the ggplot2() above
ggplotly(dnstyplt,dynamicTicks = T)
ggplotly(dnstyplt1,dynamicTicks = T)
ggplotly(dnstypltM,dynamicTicks = T)
ggplotly(dnstypltM1,dynamicTicks = T)
ggplotly(dnstypltM1,dynamicTicks = T)
#ggplts.gvar<-matrix(data =
# c(dnstyplt,dnstypltM1,dnstypltM,dnstyplt1,hstoplt,hst,BelowMuLifeExp,AbovMuLifeExp)
#lapply(X=ggplts.gvar,FUN=ggplotly(p = ggplot2::last_plot()))+facet_wrap()
#mapply(X=ggplts.gvar,FUN= ggplotly, MARGIN = 1,simplify = T)
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.